Car fleet arrival
Cars travel toward a destination at position 'target' on a single-lane road that does not allow passing. Car i starts at position[i] (0 <= position[i] < target) with constant speed[i]. A faster car that catches a slower one ahead slows to that car's speed and they travel as one 'fleet' (they arrive together); a car that catches a fleet at the target also joins it. All start positions are distinct. Return the number of distinct fleets that arrive at the target.
Implement
car_fleet(target: int, position: list[int], speed: list[int]) → intExamples
in
[12,[10,8,0,5,3],[2,4,1,1,3]]out3What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
[12,[10,8,0,5,3],[2,4,1,1,3]]3not run yetsample