729. My Calendar I
Question
Code
class MyCalendar:
def __init__(self):
self.calendar = []
def book(self, start: int, end: int) -> bool:
idx = bisect_right(self.calendar, (start, end))
if (idx > 0 and self.calendar[idx - 1][1] > start) or (idx < len(self.calendar) and self.calendar[idx][0] < end):
return False
self.calendar.insert(idx, (start, end))
return True
# Your MyCalendar object will be instantiated and called as such:
# obj = MyCalendar()
# param_1 = obj.book(start,end)