Reported February 2024
Amazoncounting

Count Distinct Passwords

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

You've got an Amazon OA in the next day or two, and you're seeing "Count Distinct Passwords" on the problem list. This is a combinatorics and counting problem that tests whether you can model constraints correctly and avoid double-counting. The trick isn't complex algorithmic machinery; it's translating the rules into the right formula. StealthCoder sits invisible during your OA as a safety net if the constraint logic doesn't click live.

Pattern and pitfall

This problem gives you rules about what makes a valid password (character types, length, forbidden patterns, etc.) and asks you to count how many distinct passwords satisfy all of them. The pattern is pure counting and math. You'll likely use combinatorics: factorial, permutations, combinations, or inclusion-exclusion to avoid overcounting overlaps. The common trap is forgetting a constraint, misapplying formula logic, or computing the complement incorrectly. Walk through the rules step by step on paper before you code. If you blank on the math during the OA, StealthCoder reads the rules and can reconstruct the model live.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Count Distinct Passwords 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Distinct Passwords FAQ

Is this asking me to generate all passwords or just count them?+

Just count them. You're deriving a formula, not brute-forcing enumeration. That's the point. Build the math model first, then code it cleanly.

What if the constraints overlap in weird ways?+

Inclusion-exclusion principle is your friend. Count the total universe, subtract violations, add back double-subtractions. Draw a Venn diagram on paper before you code if the logic feels tangled.

How do I know if my answer is right when I can't enumerate?+

Test edge cases: all characters allowed, one character forbidden, minimum length vs maximum length. Verify your formula on a small hand-computed case first.

Is this really asked at Amazon in 2024?+

Yes, reported February 2024. Amazon likes constraint-based counting problems because they test modeling skill, not just coding. Expect some variation on rules each time.

Can I code this in 30 minutes cold?+

If you nail the math model in the first 10 minutes, yes. If you're guessing the formula, you'll run out of time. Practice translating English constraints to math notation beforehand.

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