How many meetings fit in one room at most? The rules that come to mind are wrong: "take the one that starts first" can block the whole day with one long meeting; "take the shortest" can waste two long meetings with a short one that falls right between them. The rule that holds: take the one that ends earliest. A meeting that ends early leaves the most time behind it.
taken = 0free_from = float("-inf")for start, end in sorted(meetings, key=lambda m: m[1]):if start >= free_from:taken += 1free_from = endreturn taken
If the question becomes "all of them must take place; how many rooms are needed?" the idea changes: you no longer drop meetings, you count how many run at the same time. Sort the starts and the ends separately and walk the day from beginning to end: take a room at a start, give one back at an end; the most rooms held at once is the answer.