Find Min Num Moves

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

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

You've got a Microsoft OA coming in the next couple days and "Find Min Num Moves" just landed on your radar from May. This is a motion or state-space problem where you're hunting for the shortest path from one configuration to another. The pattern is classic BFS or dynamic programming, depending on whether the state space is small or the problem has optimal substructure. StealthCoder will catch the approach if you blank on whether to search or compute.

Pattern and pitfall

This problem likely asks you to find the minimum number of operations (moves, swaps, transformations) to reach a goal state from an initial state. The trick is recognizing the state space size. If it's bounded and small, BFS explores all reachable states layer by layer, guaranteeing the shortest path. If the problem has overlapping subproblems and you can describe state as a function of prior decisions, DP with memoization works faster. Common pitfall: trying greedy or brute force when the state graph is too large. StealthCoder reads the constraints in real time, so if you're unsure whether to BFS or DP, the overlay will spot the right move before you code.

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 Find Min Num 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 moves to equal array elements. If you have time before the OA, drill that.

⏵ The honest play

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

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

Find Min Num Moves FAQ

Is this a BFS problem or DP?+

Both are possible. If the state space is explicitly bounded or the problem has a clear graph structure (like a puzzle), BFS is cleaner. If you're making decisions sequentially and subproblems repeat, DP wins. Check the constraints. Constraints under 10^5 states usually lean BFS. Larger and you're likely memoizing.

What's the most common mistake on this type of problem?+

Assuming a greedy approach works. Moves that seem optimal locally often backfire. Always model the state space first. A single wrong move can add several more moves to reach the goal. That's why BFS finds the true minimum.

How do I model the state for BFS?+

Use a tuple or string representation of the configuration (board state, position, sequence, etc.). Store visited states in a set. Push each new state to the queue with the move count incremented by one. Pop from the queue; if it's the goal, return the move count.

Do I need to reconstruct the path or just return the count?+

The problem title says 'min num moves', so you're returning an integer. Reconstruction is rarely asked unless explicitly stated. Focus on counting moves, not storing them.

What if the state space is huge and BFS times out?+

Reconsider the problem constraints. There may be a mathematical pattern or closed-form solution. Or the state representation is redundant. Normalize it (sort, canonicalize) to reduce duplicates. DP with smart pruning is also an option if you can prove optimality.

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

OA at Microsoft?
Invisible during screen share
Get it