Choosing a Fleet of Vehicles
Learn this problemProblem statement
Given an integer denoting a total number of wheels, find the number of different ways to choose a fleet of vehicles from an infinite supply of two-wheeled and four-wheeled vehicles such that the group of chosen vehicles has that exact total number of wheels. Two ways of choosing vehicles are considered to be different if and only if they contain different numbers of two-wheeled or four-wheeled vehicles.
For example, if our array wheels = [4,5,6] our return array would be res = [2, 0, 2]. Case by case, we can have 1 four-wheel or 2 two-wheel to have 4 wheels. We cannot have 5 wheels. We can have 1 four-wheel and 1 two-wheel or 3 two-wheel vehicles in the final case.
Function
chooseFleets(wheels: int[]) → int[]
Complete the function chooseFleets in the editor below. The function should return an array of integers representing the answer for each wheels[i].
chooseFleets has the following parameter(s):
wheels[wheels[0],...wheels[n-1]]: an array of integers
Examples
Example 1
wheels = [6, 3, 2]return = [2, 0, 1]Constraints
1 ≤ n ≤ 1051 ≤ wheels[i] ≤ 106More JPMorgan Chase problems
- Bitwise XOR SubsequencesOA · Seen Jul 2026
- Array ChallengeOA · Seen Jun 2026
- Minimum Cores to Handle ProcessesOA · Seen Jun 2026
- About ShippingOA · Seen Jun 2026
- Count Dropped RequestsOA · Seen Jan 2026
- Generate Table of ContentsOA · Seen Jan 2026
- Calculate Net ProfitSeen Jun 2025
- Find Total WeightSeen Jun 2025