Reported March 2025
Amazonhash table

Find Replacement

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's 'Find Replacement' landed in March 2025 and it's a string-matching problem wrapped in a deceptive package. You've got a string, you've got rules for what to replace, and the obvious approach will either TLE or trip you up on overlapping matches. The trick is knowing whether to process left-to-right, use a hash table to track replacements, or lean on a single-pass algorithm. StealthCoder will have your back if the edge case logic blanks you mid-OA.

Pattern and pitfall

This is fundamentally a string-substitution problem, likely solvable with a hash table to store replacement pairs and careful iteration logic. The pitfall: candidates often try naive find-and-replace in a loop, which breaks when replacements create new matches or when you need to avoid re-processing. The pattern is usually hash-table with string building. You either build a new string character-by-character (checking against your replacement rules), or you process chunks and swap them in. Watch the order of operations. If replacements overlap or chain, you need to decide: one pass only, or allow cascading. Amazon likes this because it separates the 'I know string methods' crowd from people who think about state and iteration. StealthCoder reads the exact rules on screen and flags the edge case for you in real time.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Find Replacement 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Replacement FAQ

Is this just find-and-replace looped?+

Not safely. Looping find-and-replace can create new matches or process the same substring twice. You need either a single pass through the string with a hash table lookup, or careful state tracking. Read the problem statement twice for whether replacements can chain.

How do I handle overlapping replacements?+

That depends on the exact rules. Most Amazon versions use left-to-right greedy matching: scan once, replace as you go, don't re-scan the output. Build your result string as you move through input. Hash table lookups keep it O(n).

What's the time complexity I should target?+

O(n) where n is the input string length. You scan once, each character is processed once, hash table lookups are O(1). If you're looping or re-scanning, you're not optimal.

Should I use regex or manual parsing?+

Manual parsing is safer here. Regex can be slower and might not handle the replacement order correctly. Build a loop, check each position or chunk against your replacements, swap if match, move forward.

How much time do I have to solve this?+

Amazon OAs typically give 15-20 minutes per medium problem. 'Find Replacement' is medium difficulty. Spend 3 minutes understanding the rules, 5 minutes on logic, 7 minutes coding, 3 on edge cases. If stuck, outline the hash table approach and move on.

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