← 返回 uber 的题目列表Design Calendar Booking System
类型:online_judge
Problem: Design Calendar Booking System
Design a calendar class that supports booking half-open intervals [start, end).
If the new event overlaps with any existing event, the booking should fail and return false; otherwise, add it to the calendar and return true.
Two intervals [a, b) and [c, d) overlap if and only if:
a < d and c < b
If one event ends exactly when another starts, they do not overlap.
Implement
class MyCalendar:
def __init__(self):
pass
def book(self, start: int, end: int) -> bool:
pass
Input Format
First line: integer q, the number of booking requests.
Next q lines: two integers start end.
Output Format
Print q lines, each being true or false.
Constraints
1 <= q <= 1000
0 <= start < end <= 10^9
Example
Input:
3
10 20
15 25
20 30
Output:
true
false
true
Example
Input
3
10 20
15 25
20 30
Output
true
false
true