729. My Calendar I (Medium) - TengnanYao/daily_leetcode GitHub Wiki
class MyCalendar(object):
def __init__(self):
self.arr = []
def book(self, start, end):
"""
:type start: int
:type end: int
:rtype: bool
"""
i = bisect_right(self.arr, start)
if i == bisect_left(self.arr, end) and i % 2 == 0:
self.arr[i : i] = [start, end]
return True
return False
# Your MyCalendar object will be instantiated and called as such:
# obj = MyCalendar()
# param_1 = obj.book(start,end)