Reported February 2024
IBMbreadth first search

Get Min Moves

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

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

IBM's 'Get Min Moves' came up in February 2024 OAs, and it's a classic setup: you're given a state and need to find the minimum number of operations to reach a goal. The problem doesn't hand you the pattern on a plate. Most candidates either brute-force it (and time out) or miss that BFS or dynamic programming is the lever. StealthCoder sits in the background and feeds you the solution in real time if you freeze on the approach, so you don't burn minutes on false starts.

Pattern and pitfall

This is a shortest-path problem in disguise. You're moving from an initial state to a target state using the fewest moves possible. BFS is the standard play here: queue up the starting state, explore all neighbors (all valid moves), and return the distance when you hit the target. Common trap: trying to hand-code a mathematical formula when simulation is cleaner. Another trap: not recognizing that each 'move' is a single step, so you need to count depth in the graph, not optimize some greedy choice. If the state space is small enough, BFS runs in linear time relative to reachable states. StealthCoder validates your approach before you code, so you catch the BFS shape early and don't waste time on DP memoization when a queue solves it.

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 Get Min Moves 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimum knight moves. If you have time before the OA, drill that.

⏵ The honest play

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

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

Get Min Moves FAQ

Is this a math problem or a search problem?+

It's a search problem. You're finding the shortest path from one state to another. BFS is the standard tool. If it were pure math, IBM would ask you to derive a closed formula. Here they want the minimum operation count, which screams graph traversal.

What's the trick with 'moves'?+

Each move is a single operation that changes the state in one specific way. You need to explore all valid moves from each state and count how many steps to reach the goal. Don't overthink it. BFS counts depth naturally.

How do I know what counts as a valid move?+

The problem statement defines what operations are allowed. Common examples: swap two elements, increment/decrement by 1, flip a bit. Read carefully. The moves are usually simple. Your job is to model them as transitions in a graph.

Will this time out if I use BFS?+

BFS is optimal for unweighted shortest-path problems. If you implement it correctly (visited set to avoid cycles), it won't time out unless the state space is genuinely infinite. IBM's OA problems are designed to be solvable in the time limit with the right algorithm.

Do I need dynamic programming for this?+

Not necessarily. DP can work, but BFS is usually simpler and faster for shortest-path problems on small state spaces. Try BFS first. If it times out, then consider memoized DFS or DP. Odds are BFS is the intended solution.

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

OA at IBM?
Invisible during screen share
Get it