MEDIUMasked at 21 companies

Decode Ways

A medium-tier problem at 37% community acceptance, tagged with String, Dynamic Programming. Reported in interviews at Graviton and 20 others.

Founder's read

Decode Ways shows up in live assessments at Uber, Snap, Goldman Sachs, Salesforce, and Flipkart. You get a string of digits. You need to count how many ways it can be decoded as letters (1='A', 2='B', up to 26='Z'). The acceptance rate is 37%, which means most candidates either miss the DP pattern or fumble the edge cases around leading zeros and invalid two-digit codes. If you haven't drilled this specific problem and it lands in your OA, StealthCoder reads the prompt off your screen and solves it invisible to the proctor.

Companies asking
21
Difficulty
MEDIUM
Acceptance
37%

Companies that ask "Decode Ways"

If this hits your live OA

Decode Ways is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The trap is thinking greedy or recursion without memoization works. It doesn't at scale. You need dynamic programming. At each position, you can decode the current digit alone (if it's 1-9) or pair it with the previous digit (if together they form 10-26). The trick: handle leading zeros correctly (they're invalid), track when a two-digit code is out of range, and build a DP table where each cell represents the number of ways to decode up to that index. Most candidates get tangled on boundary conditions at position zero and one, or forget to validate the two-digit pairing. This is a classic 'obvious once you see it, invisible if you haven't' problem. StealthCoder is your safety net if the pattern doesn't click during the live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Decode Ways recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Decode Ways interview FAQ

Is Decode Ways still asked at FAANG-tier companies?+

Yes. It appears in the reported interview history of Uber, Snap, Goldman Sachs, and Salesforce among the top companies. 21 companies total have asked it. The acceptance rate sits at 37%, suggesting it's still a useful filter for mid-level assessments. Don't assume it's outdated.

What's the gotcha that kills most candidates?+

Edge cases. Leading zeros (a string starting with '0' decodes zero ways). Two-digit codes outside 10-26 are invalid. Off-by-one errors in your DP table indexing. Candidates often code the happy path, then face-plant on '06' or '27'. Test those cases first.

Do I need to know Dynamic Programming deeply to solve this?+

You need to recognize that the number of ways at position i depends on valid decodings at positions i-1 and i-2. That's the DP insight. You don't need advanced DP theory, just the ability to build a simple table and iterate. If you can think in recurrence relations, you're set.

How does Decode Ways relate to the String and DP topics?+

String handling is the surface: parsing digits, checking substrings, validating ranges. DP is the engine: memoizing overlapping subproblems (how many ways to decode from position i onward) avoids exponential recursion. Both are necessary, neither alone is sufficient.

What's the time and space complexity I should aim for?+

Time: O(n) where n is the string length. You touch each position once. Space: O(n) for the DP table, though you can optimize to O(1) by keeping only the last two values. The O(n) solution is clean and fast enough for any live OA.

Want the actual problem statement? View "Decode Ways" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.