Redian新闻
>
问一道lyft design题,求大神!
avatar
问一道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
怎么答,求大神
avatar
l*t
2
这和design没关系吧

to

【在 k*******p 的大作中提到】
: 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

avatar
s*e
3
帮顶
avatar
J*F
4
难度在哪里?在list后加一个(currenttime, currentime), 然后从后往前找,如果先
遇到一个break time over 8 hours,return true, 或者累计的work time over 12
hours, return false.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。