Most Talks in One Room
Each item of talks is [start, end] with start < end. Every talk wants the same single room, and two talks can both be held only if one ends before or exactly when the other starts. Return the largest number of talks that can be held in the room. The talks are in no particular order; return 0 if talks is empty.
Example 1
talks [[1,3],[2,5],[4,7],[6,9],[8,10]]
returns 3
[1, 3], [4, 7] and [8, 10] fit one after another; any four of the talks include two that overlap.
Example 2
talks [[0,10],[1,2],[2,3],[3,4]]
returns 3
[1, 2], [2, 3] and [3, 4] touch end to start, which is allowed; [0, 10] would block all of them.
Constraints
0 <= len(talks) <= 1000 <= start < end <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.