Skip to content
Code ReadingPicking Meetings
Predict the Output

Picking Meetings

The meeting that ends first is picked first. How many meetings are picked, and when does the last one end?
1meetings = [(1, 4), (3, 5), (0, 6), (5, 7), (8, 9), (5, 9)]
2end, count = -1, 0
3for s, e in sorted(meetings, key=lambda m: m[1]):
4 if s >= end:
5 count += 1
6 end = e
7print(count, end)