Password Strength
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's Password Strength problem is a string validation question that hits your ability to check multiple conditions in a single pass. You're given a password string and need to return how many character types are missing to make it valid, or 0 if it already qualifies. The trap is overthinking it. The pattern is straightforward: iterate once, track which categories you've seen (uppercase, lowercase, digit, special character), and count the gaps. If you blank on the logic during the OA, StealthCoder will show you the category-checking approach instantly.
Pattern and pitfall
The core trick is treating this as a counting problem, not a complex state machine. Most candidates try to build validation rules and then figure out what's missing. Instead, go the opposite direction: scan the string once and mark which of the four character types appear. Then count how many you didn't find. The length constraint (usually 6-20 chars) sometimes introduces a secondary rule about padding, but read carefully. The real gotcha is candidates who check every character individually instead of using a set or booleans to track presence. During the OA, if the logic stalls, StealthCoder bridges that gap by showing the single-pass, category-marking pattern so you can code without panic.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Password Strength 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 StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as strong password checker. If you have time before the OA, drill that.
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.
Password Strength FAQ
Do I need to validate against a dictionary or just check character types?+
Just character types. This is about missing character categories, not whether the password is a real word or matches a pattern library. The problem is purely structural: uppercase present, lowercase present, digit present, special character present. Length rules may apply too, but read the exact requirements first.
Should I loop through the string multiple times or once?+
One pass is clean and fast. Use booleans or a set to track which categories you've seen as you iterate. Don't re-scan for each character type. That's slower and unnecessary. One loop, four flags or a set, then count misses at the end.
What counts as a special character?+
The problem will define it, but typically it's any printable character that's not alphanumeric. Read the exact definition in your OA. Some specify a list like !@#$%^&*(), others say 'anything except letters and digits.' Pin this down before you code.
How hard is this compared to other Amazon OA string problems?+
It's on the easier side, closer to warm-up difficulty. The challenge isn't the algorithm, it's reading the requirements precisely and avoiding edge cases like empty strings or very short passwords. The logic itself is elementary once you see it.
Can I pass if I solve it but use an inefficient approach?+
Probably yes for this one. The string length is usually capped low, so even a slower multi-pass solution will run fine. Optimal is one loop, but don't get stuck optimizing. Correct and readable beats slow and perfect.