Ctrl K

Fewest Meetings to Cancel

Medium
A meeting room has a list of bookings meetings, where meetings[i] = [start, end] gives the start and end time of the i-th meeting. There is only one room, so meetings that run at the same time cannot all happen. Return the smallest number of meetings you have to cancel so that no two of the remaining ones overlap. A meeting that ends exactly when another one starts (for example, [1, 3] and [3, 5]) does not overlap it.
Example 1
meetings=[[9, 12], [10, 11], [11, 13], [13, 14]] → 1

The meeting [9, 12] clashes with both [10, 11] and [11, 13]. Cancel it and the rest run back to back: [10, 11], [11, 13], [13, 14].

Example 2
meetings=[[0, 5], [0, 5], [0, 5]] → 2

Three identical meetings: only one can stay, so two are cancelled.

Example 3
meetings=[[-3, -1], [-1, 4]] → 0

The meetings only touch at time -1, which is not a clash, so nothing has to be cancelled.

Constraints
  • 1 ≤ len(meetings) ≤ 10⁵
  • meetings[i].length == 2
  • -5·10⁴ ≤ start < end ≤ 5·10⁴
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsLongest Chain of Segments MediumA Haul That Splits Three Ways MediumStrongest Product Team MediumBreaking a Chocolate Bar MediumBiggest Number Divisible by Three Hard
loading Python…
Input
meetings=[[9, 12], [10, 11], [11, 13], [13, 14]]
Expected
1

Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.