Get Min Operations

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

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

JP Morgan's June 2025 OA included a problem on minimizing operations to reach a target state. This is a classic BFS or dynamic-programming puzzle where you're counting the fewest steps to transform one value into another using a fixed set of allowed moves. The trap is brute-force recursion without memoization. StealthCoder can feed you the pattern in real time if you freeze on the approach.

Pattern and pitfall

Get Min Operations typically asks: given a starting number and a target, what's the minimum number of operations (add 1, multiply by 2, etc.) to reach it. The insight is that this is a shortest-path problem in disguise. BFS explores all states at distance k before distance k+1, guaranteeing the first time you hit the target is optimal. Memoization or DP avoids revisiting the same state twice. The common mistake is a greedy attempt (always multiply when possible) which fails on many inputs. StealthCoder detects the pattern and surfaces the BFS or DP template so you don't waste 20 minutes on the wrong approach.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Get 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 StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimum operations to exceed threshold value i. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass JP Morgan's OA.

JP Morgan 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.

Get Min Operations FAQ

Is this a BFS or DP problem?+

Both can work. BFS is more intuitive for 'minimum steps' problems: treat each number as a node, each operation as an edge, and run standard BFS. DP works if you memoize the state and compute bottom-up or top-down. For JP Morgan's version, BFS is cleaner and less prone to off-by-one errors.

What's the most common wrong approach?+

Greedy: always multiply, divide, or add when it seems optimal. It fails because sometimes a 'worse' move now leads to fewer total moves later. Always validate with examples where greedy breaks (e.g., target=11 starting from 1).

How do I avoid TLE on a large target?+

BFS with a set to track visited states. Don't revisit a number. If the target is huge (e.g., 10^8), you may need to work backward from the target to 1 instead, which shrinks the search space drastically.

Should I code this in 10 minutes or think first?+

Think first. Spend 2-3 minutes sketching the state space and edges. Write BFS or DP template. Then code. Rushing into recursion without a clear plan wastes more time than thinking costs.

Is there a math shortcut?+

Not usually. The problem is fundamentally about exploring states. Some variants hint at binary representation or prime factorization, but for a standard 'min ops to N' problem, BFS or DP is the intended path.

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

OA at JP Morgan?
Invisible during screen share
Get it