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.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].
meetings=[[0, 5], [0, 5], [0, 5]] → 2
Three identical meetings: only one can stay, so two are cancelled.
meetings=[[-3, -1], [-1, 4]] → 0
The meetings only touch at time -1, which is not a clash, so nothing has to be cancelled.
meetings=[[9, 12], [10, 11], [11, 13], [13, 14]]
1
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.