Reported April 2025
Amazoncounting

Ways to Select Fleet

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon's 'Ways to Select Fleet' question showed up in April 2025 OAs and it's a combinatorics trap disguised as a selection problem. You're picking vehicles or units from a set, and the naive approach will TLE or overflow. The trick is recognizing when you need modular arithmetic and binomial coefficients. StealthCoder reads the exact constraints on screen and surfaces the math pattern in real time, so if you freeze on whether to use Pascal's triangle or a DP table, you have a backup.

Pattern and pitfall

This is a counting/combinatorics problem at its core. You'll likely need to compute C(n, k) mod some prime efficiently, which means either precomputing factorials with modular inverse or building Pascal's triangle on the fly. The catch: candidates often hardcode a single formula without reading the constraint range. If n can be up to 10^5 or 10^6, iterative factorial works. If n is smaller but multiple test cases exist, precompute. The problem may have variants (all subsets, specific sum constraints, ordering matters) so the first 90 seconds is reading the exact requirement, not coding. StealthCoder as a safety net means you can verify your modular logic the moment doubt creeps in during the live assessment.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Ways to Select Fleet cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Ways to Select Fleet FAQ

Is this asking for ordered or unordered selections?+

Read the problem statement carefully. 'Ways' usually means combinations (unordered), but 'arrangements' means permutations (ordered). If it's vague, assume combinations. The difference is factorial division vs. factorial multiplication, and it cascades through your entire solution.

What's the modulo trick here?+

If the answer must be returned mod 10^9+7, compute factorials up to n once, then use Fermat's Little Theorem to find modular inverse of divisors. Precompute inv[i] = pow(i, MOD-2, MOD) if n is under 10^6. No hardcoding, check the problem constraint.

Can I just use math.comb in Python?+

Only if the result fits in a standard int and no modulo is required. For large n or modular answers, math.comb will fail or be too slow. Know how to hand-code binomial with modular arithmetic as backup.

What if there are multiple fleets or constraints?+

The problem may ask 'select k units from fleet A and m units from fleet B'. Then it's C(n1, k) * C(n2, m) or a sum over valid splits. Read for constraints on total selections, budget, or interdependencies before you code.

How do I avoid overflow in the live assessment?+

Work modulo the specified prime from the start. Never compute the raw factorial and hope it fits. Every multiplication and division happens inside the mod arithmetic. If the problem doesn't specify a mod, it's a red flag, ask or assume 10^9+7.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it