There are n cars going to the same destination along a one-lane road, target miles away. Given position and speed arrays, a car cannot pass the car ahead of it — it merges into a fleet at that car's speed instead. Return the number of car fleets that will arrive at the destination.
Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]
Output: 3
Topics: stack, sorting, arrays
Asked by: Google, Amazon
Time complexity: O(n log n). Space complexity: O(n).