Algorithm · Airbnb · Hard
A two-by-three sliding puzzle contains six cells arranged in two rows and three columns. The cells hold the integers 0 through 5, each exactly once, and the cell containing 0 is the blank. A legal move swaps 0 with a value that is directly to its left, right, above, or below. Given a starting board board, return the minimum number of legal moves required to reach [[1, 2, 3], [4, 5, 0]]. If that target cannot be reached, return -1. An already-solved board should return 0.…
Checking your access…