Skip to content

Instantly share code, notes, and snippets.

Embed
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)
queue.push(o_in)
queue.push(o_out)
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
You can’t perform that action at this time.