To fit the most activities into one room, sort them by finish time and walk down the list, taking each activity that starts no earlier than the last one you took ends. One sort and one pass.
- Average time
- O(n log n)
- Space
- O(1)
To fit the most activities into one room, sort them by finish time and walk down the list, taking each activity that starts no earlier than the last one you took ends. One sort and one pass.