Skip to main content
Car Fleet | AlgoCracked
AlgoCracked
ProblemsCar Fleet
Medium52.0% acceptance
Blind75ArrayStackSortingMonotonic Stack

Car Fleet

There are n cars on a one-lane road heading to a destination at position target . Car i starts at position[i] and drives at a constant speed[i] . A faster car can never pass a slower one; instead it catches up and travels as a fleet at the slower car's speed. Cars that meet exactly at the target count as one fleet. Return the number of car fleets that reach the target. Input format Input is [target, position, speed] , e.g. [12,[10,8,0,5,3],[2,4,1,1,3]] .

Loading workspace…