You are given an integer representing a total count of wheels. Your task is to determine how many distinct ways you can form a group of vehicles using an unlimited supply of two-wheeled and four-wheeled types such that the sum of their wheels equals the given total.
Two arrangements are considered unique if the count of two-wheeled or four-wheeled vehicles used differs between them.
The function should return a list of integers, where each value corresponds to the number of valid combinations for the respective total in the input list.
Constraints
1 ≤ n ≤ 10^51 ≤ wheels[i] ≤ 10^9
Examples
01 Β· Example 1
wheels = [6, 3, 2] return = [2, 0, 1]
For a total of 6 wheels:
Option 1: One four-wheeled vehicle + one two-wheeled vehicle
Option 2: Three two-wheeled vehicles
Total combinations = 2
π¦ π¦ π π’ π π¦ πͺ π¦ 𦀠πͺΏ 𦩠π¦§
For 3 wheels:
No possible arrangement can sum to 3 wheels using only 2- and 4-wheeled vehicles
Total combinations = 0
π π π π π₯ π₯ π₯ π
πβπ© π π₯₯ π
For 2 wheels:
Only possible using one two-wheeler
Total combinations = 1
02 Β· Example 2
wheels = [4, 5, 6] return = [2, 0, 2]
For 4 wheels: either 1 four-wheeler or 2 two-wheelers.
For 5 wheels: it is impossible.
For 6 wheels: either 1 four-wheeler + 1 two-wheeler or 3 two-wheelers.
More Amazon problems
- Count Promotional PeriodsOA Β· Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA Β· Seen Jun 2026
- Find Minimum CostOA Β· Seen Jun 2026
- Get Smallest Base SegmentOA Β· Seen Jun 2026
- Select Least Resource TasksOA Β· Seen Jun 2026
- Product Category Group SizesPHONE SCREEN Β· Seen May 2026
- Count Connected ComponentsPHONE SCREEN Β· Seen May 2026
public int[] countWaysToSelectFleet(int[] wheels) {
// write your code here
}
wheels[6, 3, 2]
expected[2, 0, 1]
sign in to submit