Skip to content
RED SAGSkills
easy15 ptsintervals

Can One Person Attend Every Booking?

Each entry [start, end] of bookings is a meeting that occupies the half-open time span start <= t < end. The bookings are in no particular order.

Return true if one person can attend all of them, meaning no two bookings overlap. A booking that ends exactly when another starts does not overlap it.

Example 1

Input: bookings = [[0,30],[5,10],[15,20]]
Output: false
Explanation: [0,30] overlaps both other meetings.

Example 2

Input: bookings = [[7,10],[2,4]]
Output: true
Explanation: The two meetings are far apart.

Constraints

  • 0 <= bookings.length <= 2 * 10^4
  • 0 <= start < end <= 10^6
Hint 1

Sort the bookings by start time.

Hint 2

After sorting, it is enough to compare each booking with the one right before it.

Good practice for: Frontend Developer, Backend Developer, Full Stack Developer, Mobile App Developer, Automation Test Engineer

Run checks your code on 3 sample tests. Submit runs all 9 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.