Description

Implement a calendar that can add new events without causing a double booking. A double booking occurs when two events have some non-empty intersection.

Examples

Input:["book",10,20],["book",15,25],["book",20,30]
Output:[true,false,true]
Explanation:

[15,25] overlaps with [10,20].

Input:input = [[10,20],[15,25],[20,30]]
Output:false
Explanation:

For input = [[10,20],[15,25],[20,30]], the answer is false because the my calendar i condition is not met.

Input:["book",5,15],["book",16,25],["book",14,17],["book",25,30]
Output:[true,true,false,true]
Explanation:

First booking [5,15] succeeds. Second booking [16,25] succeeds as it starts after first ends. Third booking [14,17] fails because it overlaps with [5,15] (ends at 15, starts at 14). Fourth booking [25,30] succeeds as it starts exactly when [16,25] ends with no overlap.

Constraints

  • 0 ≤ start < end ≤ 10⁹
  • At most 1000 calls to book

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!