Reported March 2024
Amazoncounting

Num of Possible Unique Strings

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 hit you with a string uniqueness problem in March 2024, and the title hints at permutations or combinatorial counting. You're likely building unique strings under some constraint, and the trap is overthinking the generation versus calculating the answer mathematically. This is a counting or dynamic programming play, not a brute-force string builder. If you blank during the OA, StealthCoder reads the full constraint set on screen and feeds you the pattern in real time so you don't waste 20 minutes on the wrong approach.

Pattern and pitfall

The core move here is recognizing whether you need to enumerate strings (simulation) or compute the count (math or DP). Most candidates default to generation; the intended solution is usually a formula or DP table. Common constraints: fixed character set, wildcard positions, character frequency limits, or replaceable placeholders. Work backward from what makes strings unique. If there are N positions and K choices per position, it's K^N. If choices are constrained by state (previous character, remaining budget), build a DP. StealthCoder gives you the exact constraints when you're live, so you won't misread the problem and burn 15 minutes on the wrong algorithm.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Num of Possible Unique Strings 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 would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as unique paths. If you have time before the OA, drill that.

⏵ 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 would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Num of Possible Unique Strings FAQ

Is this a permutation or combination problem?+

Neither directly. It's counting distinct valid strings given rules. If order matters and characters can repeat, it's closer to permutation with repetition. If you're selecting without replacement, combination. Read the constraint carefully: can you reuse characters, are some positions fixed, do characters have limited supply.

Should I generate all strings or calculate the count?+

Calculate. If the answer is in the millions, generation fails. Assume the string space is large. Use a formula (exponential or factorial) or DP with memoization to count states, not enumerate them.

What's the most common mistake on this problem?+

Misreading the constraint. Candidates assume all characters are valid everywhere, missing that some positions are fixed or some characters are forbidden. Read twice. If a wildcard or placeholder is mentioned, that's your degree of freedom.

How do I handle wildcards or replaceable characters?+

Each wildcard is a choice point. If position i is a wildcard and you have K valid characters, contribute a factor of K to the count. If wildcards are independent, multiply. If they're constrained (no adjacent duplicates), use DP to track the previous character state.

Is this still asked by Amazon in 2024?+

Yes. It's a classic Amazon combinatorics filter. Expect a variant. The title might say 'unique paths', 'unique strings', or 'ways to build'. The pattern is always count under constraint, not enumerate.

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