n cars drive on a one-lane road towards the same destination, which is target km from the start. For car i, position[i] is the place where it starts (in km) and speed[i] is its speed (in km per hour).
A car cannot overtake another car. When a faster car comes up behind a slower car, it slows down and drives right behind it at the same speed. We ignore the gap between them: they are treated as being at the same place.
A car fleet is one or more cars that drive together at the same place and speed. A single car is also a fleet. A car that catches a fleet exactly at the destination still counts as part of that fleet.
Return the number of fleets that arrive at the destination.
Examples
Example 1:
Input: target = 100, position = [0,10,40,70], speed = [10,10,5,20]
Output: 2
Explanation: The car at 70 is fast and alone in front. The cars at 40, 10 and 0 all end up behind the slow car at 40, so they form one fleet. There are 2 fleets.
Example 2:
Input: target = 12, position = [0,4,6], speed = [1,1,3]
Output: 3
Explanation: The car at 6 arrives first. The cars behind it are too slow to catch up. There are 3 fleets.
Example 3:
Input: target = 20, position = [16,12,8], speed = [1,2,3]
Output: 1
Explanation: All three cars need exactly 4 hours. They meet at the destination, which counts as one fleet.