Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2015 16:48
What would you like to do?
class Item(object):
def __init__(self, time, val):
self.time = time
self.val = val
def get_over_limit_simul(interval_list, limit):
queue = Queue(lambda o: o.time)
for interval in interval_list:
o_in = Item(interval.start, interval.val)
o_out = Item(interval.end, -1 * interval.val)
cap = 0
while len(queue) > 0:
item = queue.pop()
cap += item.val
if cap > limit:
return False
assert(cap >= 0)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment