Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ddec5ad

Browse files
Create Solution.py
1 parent 0eea170 commit ddec5ad

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎My Calendar I/Solution.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class MyCalendar:
2+
3+
def __init__(self):
4+
self.cal = []
5+
6+
def book(self, start: int, end: int) -> bool:
7+
i = bisect_left(self.cal, (start,end))
8+
if (i-1>=0 and self.cal[i-1][1]>start) or (i!=len(self.cal) and self.cal[i][0]<end):
9+
return False
10+
self.cal.insert(i,(start,end))
11+
return True
12+
13+
14+
15+
16+
# Your MyCalendar object will be instantiated and called as such:
17+
# obj = MyCalendar()
18+
# param_1 = obj.book(start,end)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /