My Calendar III
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Events are added to a calendar one at a time, and every event is accepted. Each event is a half-open interval [startTime, endTime) covering every time t with startTime <= t < endTime.
A *k-booking* happens when some moment is covered by k events at the same time.
- MyCalendarThree() creates an empty calendar.
- book(startTime, endTime) adds the event and returns the largest k such that the calendar, including all events so far, contains a k-booking.
Events that only touch at an endpoint (one ends at x, the other starts at x) do not overlap.
Examples
Constraints
- `0 <= startTime < endTime <= 10^9`
- At most 400 calls to `book`.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.