问一道lyft design题,求大神!# JobHunting - 待字闺中
k*p
1 楼
function to determine whether the driver is allowed to enter driver mode
* drivers are not allowed to drive a total of 12 hours without an 8 hour
break
* the function inputs are:
- a list of driver shifts as start/end integers, the integer is relative to
lyft launch
- the current time since lyft launch as integer
def can_drive(history, current_time):
"""
Returns true if the driver has driven less than 12 hours since their
last 8 hour break
history|array - Shifts, e.g. [(0, 12), (13, 19)]
current_time|int - Current timestamp as hour since Lyft launch, e.g. 50
can_drive = True example
# 9 hour break, 1 hour shift, 2 hour break, 10 hour shift
history = [(9, 10), (12, 22)]
current_time = 24
can_drive = False example:
history = [(0, 4), (5, 9), (10, 14), (15, 19), (20, 24)]
current_time = 24
怎么答,求大神
* drivers are not allowed to drive a total of 12 hours without an 8 hour
break
* the function inputs are:
- a list of driver shifts as start/end integers, the integer is relative to
lyft launch
- the current time since lyft launch as integer
def can_drive(history, current_time):
"""
Returns true if the driver has driven less than 12 hours since their
last 8 hour break
history|array - Shifts, e.g. [(0, 12), (13, 19)]
current_time|int - Current timestamp as hour since Lyft launch, e.g. 50
can_drive = True example
# 9 hour break, 1 hour shift, 2 hour break, 10 hour shift
history = [(9, 10), (12, 22)]
current_time = 24
can_drive = False example:
history = [(0, 4), (5, 9), (10, 14), (15, 19), (20, 24)]
current_time = 24
怎么答,求大神