Back to problems

Last Truck to Leave a Lane

Algorithm · Uber · Hard

Last Truck to Leave a Lane Medium · Topics · Company Tags · Hints Imagine a straight road of length L, extending from coordinate 0 to L. On this road there are n trucks, each initially parked at a unique location. Truck number i starts at coordinate position[i] and travels with a constant speed velocity[i]. A positive speed means the truck drives rightward, toward L; a negative speed means it drives leftward, toward 0. A truck leaves the road the instant its coordinate…

Checking your access…