Skip to content

Commit 81abc9f

Browse files
Create 732_My_Calendar_III.py (qiyuangong#64)
* Added solution for Add 732_My_Calendar_III.py problem from Leetcode Contributed by @parkjonggyeong18
1 parent a4519f3 commit 81abc9f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/732_My_Calendar_III.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)