Search
⌘K

Leetcode 773. Sliding Puzzle

Given a 2x3 sliding puzzle with tiles 1–5 and a blank (0), find the minimum number of swaps of 0 with its 4-directional neighbors to reach the target [[1,2,3],[4,5,0]] (or return -1 if impossible). This is a shortest-path search in the permutation state graph (solvable via BFS/heuristic search due to the small state space).

Asked at:

Amazon

Amazon

Microsoft

Microsoft


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late October, 2025

Microsoft

Microsoft

Mid-level

Late April, 2025

Amazon

Amazon

Mid-level

Comments

Your account is free and you can post anonymously if you choose.