There are n cars at given positions on a single-lane road heading to the same destination target miles away. You are given arrays position and speed, where position[i] and speed[i] are the position and speed of the i-th car. A car can never pass another car ahead of it, but it can catch up and then drive bumper to bumper at the same speed. The faster car slows down to match the car ahead, and the pair forms a single car fleet. A single car is also a fleet. Return the number of car fleets that will arrive at the destination.
Example 1
Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]
Output: 3
Explanation: Each car's time to reach 12 is (12 - position) / speed: 10 → 1, 8 → 1, 5 → 7, 3 → 3, 0 → 12. Cars at 10 and 8 arrive together (one fleet). The car at 3 catches the slower car at 5 (another fleet). The car at 0 never catches up (a third fleet).
Example 2
Input: target = 10, position = [3], speed = [3]
Output: 1
Explanation: There is only one car, so it forms one fleet.
Example 3
Input: target = 100, position = [0,2,4], speed = [4,2,1]
Output: 1
Explanation: The arrival times are 25 (car at 0), 49 (car at 2) and 96 (car at 4). The cars behind are faster, so both catch the car at 4, and all three arrive as one fleet.
Process cars from the one closest to the target backwards. A car behind joins the fleet ahead only if it would arrive no later; otherwise it starts a new fleet.
Run checks all cases above. Submit evaluates all test cases.