← 返回 uber 的题目列表My Calendar I
类型:qbank
Implement a calendar that stores booked half-open intervals [start, end), accepting a new event only if it does not overlap any existing booking.
My Calendar I
Implement a calendar that stores booked half-open intervals [start, end), accepting a new event only if it does not overlap any existing booking.
SWE
interval
data-structure
medium
Frequency
Single report
Last asked
2026-01-09
Stage
onsite-coding
My Calendar I
Implement a calendar that stores booked half-open intervals [start, end).
A booking is valid only if it does not overlap with any existing booking. Return true when the event can be added and false otherwise.
Examples
Example 1:
Input: ["MyCalendar","book","book","book"] [[],[10,20],[15,25],[20,30]]
Output: [null,true,false,true]
Constraints
0 <= start < end <= 10^9
At most 1000 calls will be made to book.
Notes
Equivalent to LeetCode 729.