bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 731. My Calendar II

731. My Calendar II

Leetcode Solutions

Boundary Count Approach

  1. Initialize a data structure to keep track of the changes in active events at each point in time.
  2. For each booking request, increment the counter at the start time and decrement it at the end time.
  3. Process the times in sorted order, keeping a running total of active events.
  4. If the running total reaches 3 at any time, the booking would cause a triple booking, so return false.
  5. If the booking is valid, update the data structure with the new event and return true.
UML Thumbnail

Brute Force Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...