Fewest Spins to Finish a Board Game With Shortcuts and Chutes
Last updated: November 29, 2026
Quick Overview
A square board numbers its cells 1 to n*n in a back-and-forth pattern starting from the bottom-left, and some cells jump you to another cell. Each spin moves you forward 1 to 6 cells; return the minimum spins to reach the last cell, or -1.
Meta
November 29, 20260
0
0 solved
A square board numbers its cells 1 to n*n in a back-and-forth pattern starting from the bottom-left, and some cells jump you to another cell. Each spin moves you forward 1 to 6 cells; return the minimum spins to reach the last cell, or -1.
Fits a Meta phone screen as a BFS problem dressed as a casual game, the sort of thing found in Facebook Gaming. Most of the difficulty is in mapping a square number to a row and column correctly. The interviewer watches for that conversion and for jumps applied at most once per move.
What the Interviewer Expects
- Model squares as nodes and spins as unit-weight edges
- Convert square numbers to coordinates with alternating row direction
- Apply a jump exactly once per move without chaining
- Use BFS with a visited set on landing squares
- Return -1 when unreachable
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if jumps could chain?
- How would you return the actual sequence of spins?
- What if the spinner were weighted, so you want the most likely fastest route?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Board is
n x nwith2 <= n <= 20;board[r][c]is -1 or a destination square. - Square 1 is bottom-left; rows alternate direction going up.
- Jumps are taken only at the end of a spin and do no...
High-Level Design
Every square is a node and each spin is a unit-weight edge to up to six squares, redirected if that square has a jump. BFS gives the minimum number of spins. The only tricky part is indexing: for squa...