Vehicle Mixes for a Wheel Total
Updated
Problem statement
There are two kinds of vehicles. A four-wheeler has 4 wheels and a two-wheeler has 2 wheels. You are told only the total number of wheels, totalWheels.
A mix is a pair of whole numbers: how many four-wheelers (f) and how many two-wheelers (t). It fits when 4 * f + 2 * t == totalWheels.
fandtcan each be0, so a mix may use only one kind of vehicle.- Two mixes are different when their
fvalues differ or theirtvalues differ. - If no mix fits, the answer is
0.
Return the number of different mixes that fit.
Function
countVehicleMixes(totalWheels: int) → intExamples
Example 1
totalWheels = 12return = 4Every mix with 12 wheels:
0four-wheelers and6two-wheelers:0 + 12 = 12.1four-wheeler and4two-wheelers:4 + 8 = 12.2four-wheelers and2two-wheelers:8 + 4 = 12.3four-wheelers and0two-wheelers:12 + 0 = 12.
That is 4 mixes. A mix may leave out one kind of vehicle.
Example 2
totalWheels = 7return = 0Every vehicle has an even number of wheels, so any mix has an even total. No mix reaches 7, so the answer is 0.
Example 3
totalWheels = 2return = 1The only mix is one two-wheeler. Four-wheelers do not fit in 2 wheels.
Constraints
1 <= totalWheels <= 10^9
More DocuSign Online Assessment questions
- Max Sum With No Two Adjacent PicksOA · Seen Apr 2026
- Max Sum With No Two Adjacent Picks on a CircleOA · Seen Apr 2026
- Beautiful Number OrderingsOA · Seen Feb 2026
- Grid Path With the Most ClearanceOA · Seen May 2025
- Count Sales Rung Up at the Wrong PriceOA · Seen Feb 2021
- Most Disjoint Intervals From Starts and DurationsOA · Seen Feb 2021
- Fewest Fountains to Water the GardenOA · Seen Feb 2021
- Lowest Start That Keeps Running Totals PositiveOA · Seen Feb 2021
- Fewest Student Groups Within a Level GapOA · Seen Nov 2020
- Alphabetize a Word ListOA · Seen May 2020
Similar questions at other companies
- Count Valid Square PairsAuxoAI · OA
- Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions