Created
February 20, 2019 07:09
-
-
Save newjam/72f0be850d3465840bd1928ac2953cc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from heapq import heappush, heappop | |
schedule = [(1, 3), (2, 5), (4, 5)] | |
def required_rooms(schedule): | |
h = [] | |
for start, end in schedule: | |
if len(h) > 0 and h[0] <= start: | |
heappop(h) | |
heappush(h, end) | |
return len(h) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment