My Calendar II
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
Build a calendar that accepts new events as long as no moment would be covered by **three** events at once. Double bookings are allowed; triple bookings are not.
Each event is a half-open interval [startTime, endTime): it covers every real time t with startTime <= t < endTime. So an event ending at 10 and another starting at 10 do not overlap.
- MyCalendarTwo() creates an empty calendar.
- book(startTime, endTime) adds the event and returns true if doing so creates no triple booking. Otherwise it returns false and the event is **not** added.
Examples
Constraints
- `0 <= startTime < endTime <= 10^9`
- At most 1000 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.