Coding Challenge

Car Fleet

Medium
stacksorting

Count how many car fleets reach the target.

Cars travel toward a target at different speeds. A faster car that catches a slower one becomes part of the same fleet. Return the number of fleets reaching the target.

Examples

Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]

Output: 3

Constraints

  • Cars are unique positions

Preparing your coding workspace...