You want to throw a party and a few of your friends are willing to help at the bar for a part of the night. For example
Design an efficient algorithm that, given a list of hours with people who want to help, checks if there is someone in the bar at every point between a given start time and end time.
Write a Python function party(intervals: list, start: int, end: int)
that checks if there are enough helpers between the given start time and end time.
A tuple with 2 elements (start_time, end_time)
is used to model a time interval. Timestamps are represented as simple integers. Note: The start time is inclusive, but the end time is exclusive.
>>> party([(592, 628), (646, 700), (556, 610), (631, 643)], 592, 700)
False
>>> party([(592, 628), (646, 700), (556, 610), (592, 646)], 592, 700)
True
>>> party([(100, 101)], 100, 101)
True
>>> party([], 100, 101)
False
>>> party([], 100, 100)
True