I used a Breadth-First Search (BFS) starting from square 1 to simulate the minimum number of dice rolls needed to reach the final square. I converted the square numbers into board coordinates by carefully accounting for the alternating row direction (boustrophedon layout). At each step, I explored all possible dice rolls (1 to 6), checked if a ladder or snake redirected the move, and added the resulting square to the queue if it hadn’t been visited.
class Solution:
def snakesAndLadders(self, board: List[List[int]]) -> int: