Find Min Operations
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's Find Min Operations question hit candidates in February 2024, and it's a deceptive greedy or BFS trap. You're given some state and need to reach a target with the minimum number of operations. The trick isn't brute force; it's spotting which operations actually shrink the problem space. If you blank on the live OA, StealthCoder reads the exact operations allowed and surfaces the optimal path in real time, so you're never guessing between greedy and dynamic programming.
Pattern and pitfall
Find Min Operations typically asks you to transform one value into another using a fixed set of allowed operations (like divide by 2, subtract 1, or multiply by specific constants). The key is recognizing this as a shortest-path problem: BFS on a graph where nodes are states and edges are operations. Greedy fails because an operation that looks good locally (e.g., always dividing) can trap you. DP or BFS guarantees the minimum. Common pitfall: candidates try to reverse-engineer from target to source instead of forward search, burning time. Amazon variants sometimes add constraints on which operations are valid. StealthCoder catches the operation set immediately and avoids the false-optimization rabbit hole.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Find Min Operations 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 would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as minimum genetic mutation. 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 would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find Min Operations FAQ
Is this a BFS or greedy problem?+
BFS. Greedy fails because local gains don't guarantee global optima. You need to explore all reachable states level by level. If you see a problem where any operation choice seems tempting, it's BFS.
Should I work forwards or backwards?+
Forward (source to target) is standard and intuitive. Bidirectional BFS is faster but harder to code under pressure. Stick with forward unless the numbers are huge.
What's the most common mistake candidates make?+
Assuming division or subtraction is always better. They skip operations that seem inefficient, then realize they're stuck. Explore all branches at each step.
How do I code this in 15 minutes?+
Use a queue, a visited set, and a steps counter. Dequeue, apply each operation, check if new state is target, enqueue unvisited states. Simple BFS template.
Will this question appear again at Amazon?+
Yes. Min operations is a classic Amazon pattern. The specific operations change, but the structure doesn't. Learn the BFS template now.