dsa · easy

Two-Wheeler / Four-Wheeler Count

GreyOrangeMathArrayFoundation

For each n in nums, return the **minimum number of vehicles** whose wheels sum to n. Each vehicle is a 2-wheeler or a 4-wheeler. Prefer as many 4-wheelers as possible. If n is odd, no combination works — return 0.

Arguments

**Example:** [6, 3, 2][2, 0, 1] (6 = one 4 + one 2; 3 is impossible; 2 = one 2-wheeler).

Constraints

1 <= nums.length <= 1000, 0 <= nums[i] <= 10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[6,3,2]

Expected:
[2,0,1]

Example 2

Input:
[4]

Expected:
[1]

Open in the Dojo editor