We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4519f3 commit 81abc9fCopy full SHA for 81abc9f
python/732_My_Calendar_III.py
@@ -0,0 +1,17 @@
1
+from sortedcontainers import SortedDict
2
+
3
4
+class MyCalendarThree:
5
+ def __init__(self):
6
+ self.timeline = SortedDict()
7
8
+ def book(self, start: int, end: int) -> int:
9
+ self.timeline[start] = self.timeline.get(start, 0) + 1
10
+ self.timeline[end] = self.timeline.get(end, 0) - 1
11
12
+ ans = 0
13
+ activeEvents = 0
14
15
+ for count in self.timeline.values():
16
+ activeEvents += count
17
+ ans = max(ans, activeEvents)
0 commit comments