You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while j < len(passengers) and passengers[j] <= buses[i]:
cnt += 1
j += 1
cnt = max(cnt-capacity, 0)
j -= max(cnt-capacity, 0)
cnt = min(cnt, capacity)
while j < len(passengers) and passengers[j] <= buses[-1] and cnt+1 <= capacity:
cnt += 1
j += 1
return buses[-1] if cnt < capacity and (j-1 < 0 or passengers[j-1] != buses[-1]) else next(passengers[i]-1 for i in reversed(xrange(j)) if i-1 < 0 or passengers[i]-1 != passengers[i-1])