A classic board game converted to unweighted shortest path: every die roll (1 through 6)
costs 1 move. BFS guarantees the minimum die rolls to reach square n².
The main gotchas are mapping 1D square numbers to the Boustrophedon 2D grid, taking at most
one snake or ladder per turn, and marking seen on push to avoid infinite loop trapdoors!
"Each turn allows 6 possible moves (die roll 1 to 6), each with uniform cost 1. Therefore, finding the minimum number of rolls is an unweighted shortest path problem solved via BFS."
"Row from top: r = n - 1 - (s - 1) / n. Column flips every other row from bottom: int rem = (s - 1) % n; int c = ((n - 1 - r) % 2 == 1) ? n - 1 - rem : rem;"
"If a square has a snake or ladder (board[r][c] != -1), we jump immediately to destination d = board[r][c]. Crucially, we mark seen[d] = true on push, NOT the square we landed on before teleporting."
"There are $n^2$ squares. Each square is enqueued at most once, and each roll considers 6 edges. Time is strictly $O(n^2)$ and auxiliary space is $O(n^2)$."