Reported August 2023
Goldman Sachsstring

Decoding String

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

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

You're facing Goldman Sachs' Decoding String problem in August 2023. The ask is straightforward: reverse a digit string, then parse it back into ASCII characters. The trap is that ASCII values are not uniform length. Lowercase letters sit in the 97-122 range (two digits), uppercase in 65-90 (two digits), and some printable chars require three digits. You need to know the valid ranges cold and build a parser that tries to greedily consume valid values from right to left. StealthCoder can anchor your logic if you blank on the ranges during the live OA.

The problem

Many simple encoding methods have been devised over the years. A common method is the ASCII character set used to display characters on the screen. Each character is given a numeric value which can be interpreted by the computer. To decode the string, first reverse the string of digits, then successively pick valid values from the string and convert them to their ASCII equivalents. Some of the values will have two digits, and others three. Use the ranges of valid values when decoding the string of digits. Given a string, decode it following the steps mentioned above. Complete the function decode. decode has the following parameter(s): string: the original decoded string decode.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The algorithm hinges on reverse-then-parse. Reverse the digit string first. Then iterate backward through the result, at each step trying to consume either a two-digit or three-digit substring and checking if it maps to a valid ASCII character in the allowed ranges. The greedy choice matters: try three digits first (if it's valid, take it), else fall back to two digits. If neither works, you've hit an invalid encoding. Common pitfall: off-by-one errors when slicing, or confusing the order of operations. Many candidates reverse conceptually but parse forward, inverting the intent. StealthCoder handles the state machine that decides two vs three digits, so if your mental model cracks under time pressure, you have the pattern live.

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 Decoding String 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 Goldman Sachs's OA.

Goldman Sachs 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.

Decoding String FAQ

What ASCII ranges do I need to memorize?+

Uppercase A-Z: 65-90 (two digits). Lowercase a-z: 97-122 (two digits). Digits 0-9: 48-57 (two digits). Space: 32 (two digits). Some printable punctuation: 33-47, 58-64, 91-96, 123-126 (all two or three digits). Avoid memorizing; test a few known chars and infer.

Do I reverse the string first or parse then reverse?+

Reverse the string first, then parse. You're reading the reversed digit sequence from left to right, greedily pulling off valid ASCII values. This is the canonical approach; don't invert it.

What happens if neither two nor three digits is valid at a position?+

That's a malformed input. The problem statement doesn't specify error handling, so assume the input is always well-formed. But in production, you'd return an error or empty string. Check the problem spec for edge cases.

Should I try three digits first or two?+

Try three digits first, then two. If a three-digit value is valid (in range), consume it. If not, backtrack and try two digits. This greedy approach resolves ambiguity. Some decoders do it the other way; test with the examples.

Is this problem on LeetCode or a Goldman original?+

It's a custom problem, not a direct LeetCode port. The mechanics are similar to string parsing and state machines, but the ASCII decoding twist is specific to Goldman. Expect custom test cases to be strict on edge cases and range boundaries.

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

OA at Goldman Sachs?
Invisible during screen share
Get it