773. sliding puzzle difficulty: hard topics: array, breadth-first search, matrix on an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. a move consists...
在一个2x3的滑动拼图中,有5个数字和一个空格。目标是通过交换空格与相邻数字,达到状态[[1,2,3],[4,5,0]]。使用广度优先搜索(bfs)算法探索所有可能的配置,返回最少移动次数,若无法解决则返回-1。