Skip to content

Instantly share code, notes, and snippets.

@newjam
Created February 20, 2019 07:09
Show Gist options
  • Save newjam/72f0be850d3465840bd1928ac2953cc5 to your computer and use it in GitHub Desktop.
Save newjam/72f0be850d3465840bd1928ac2953cc5 to your computer and use it in GitHub Desktop.
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