Skip to content

Commit 7055731

Browse files
authored
Create count-days-without-meetings.py
1 parent 9551775 commit 7055731

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Python/count-days-without-meetings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Time: O(nlogn)
2+
# Space: O(1)
3+
4+
# sort
5+
class Solution(object):
6+
def countDays(self, days, meetings):
7+
"""
8+
:type days: int
9+
:type meetings: List[List[int]]
10+
:rtype: int
11+
"""
12+
meetings.sort()
13+
result = curr = 0
14+
for s, e in meetings:
15+
result += max((s-1)-curr, 0)
16+
curr = max(curr, e)
17+
result += days-curr
18+
return result

0 commit comments

Comments
 (0)