Reported September 2026
Amazonhash table

Environment Variable Store and Substitution

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

The whole Amazon question from September 2026 hinges on one hash map. That's the data structure doing the real work in this environment variable store. You get SET, GET and PARSE operations, and you return outputs only for GET and PARSE. It looks like string parsing, but the map is the backbone and the scan is the part people botch. If you've got an Amazon OA invite and 48 hours, this one is very doable once you see the shape. StealthCoder sits invisibly as a safety net if you blank on the PARSE scanning logic during the live assessment.

The problem

Process a sequence of environment-variable operations:
["SET", key, value] stores or overwrites a value.
["GET", key] emits the value or NULL when missing.
["PARSE", text] emits text after replacing every complete %KEY% placeholder whose key exists. Missing placeholders remain unchanged.
Substitution is one pass: replacement values are not expanded again during the same operation.

Function
processEnvironment(operations: String[][]) → String[]

Examples
Example 1
operations = [["SET","NAME","Tom"],["PARSE","Hello I am %NAME%"]]
return = ["Hello I am Tom"]
The stored NAME value replaces its placeholder.
Example 2
operations = [["GET","MISSING"],["PARSE","%MISSING%"]]
return = ["NULL","%MISSING%"]
Missing GET and PARSE have distinct deterministic outputs.

Constraints
1 <= operations.length <= 10^5.
Keys contain letters, digits, or underscores and are nonempty.
Each operation row has the required fields.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Keep a hash map from key to value. SET overwrites, GET returns the value or the string NULL. PARSE is where people lose points. Scan the text left to right. When you hit a percent sign, look for the next percent sign. If the substring between them is nonempty, valid, and exists in the map, append the value and jump past the closing percent. Otherwise append the literal percent and move on by one character. Build the output with a list or builder, not repeated concatenation. Single pass means you never rescan the appended value, so a value containing %X% stays as is. The classic pitfall is consuming the closing percent when the key is missing, which breaks cases like %A%B%. With up to 10^5 operations, keep each PARSE linear in text length. If you freeze on the pointer logic live, StealthCoder can hand you the working scan.

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 Environment Variable Store and Substitution 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 Amazon's OA.

Amazon 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.

Environment Variable Store and Substitution FAQ

What's the trick in the Amazon environment variable substitution problem?+

Use a hash map for the variables and a single left-to-right scan for PARSE. Find a percent, find the next percent, look up the key between them. If it exists, append the value and skip past both. If not, emit the first percent literally and continue from the next character.

How hard is this OA question really?+

Easy to medium. No fancy algorithm is involved. The difficulty is edge cases in PARSE, like unmatched percents, empty keys, adjacent placeholders, and missing keys. If you write the scan carefully and test those, it's a short solution.

Do replacement values get expanded again?+

No. Substitution is one pass, so if a stored value contains something like %OTHER%, it stays literal in the output for that operation. Append the value to your result and move the index past the original placeholder, never rescanning what you appended.

What should GET and PARSE return for missing keys?+

GET on a missing key emits the string NULL. PARSE leaves a missing placeholder unchanged, including both percent signs. Example 2 shows both: GET MISSING gives NULL, and PARSE of %MISSING% gives %MISSING%. Don't mix those two behaviors up.

How do I prep this in 48 hours?+

Write the solution once from scratch with a hash map and a manual index scan. Then test strings like %A%B%, %%, a lone percent, and back-to-back placeholders. Also confirm you only output for GET and PARSE, not SET. Two clean runs is enough.

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