[JavaScript] Easy to understand - BFS - 128ms
Since we need to find out the minimum steps from one fixed point to another fixed point. The straight forward solution to do this is BFS.\n\n- Maintain a visite
Since we need to find out the minimum steps from one fixed point to another fixed point. The straight forward solution to do this is BFS.\n\n- Maintain a `visited` set to prevent endless loop\n- Use `x`, `y` and `status` to identifies a status uniquely\n- Traversal all possible status for current step and get the possible status for next step\n- Finally get the answer\n\n```js\nconst minimumMoves = grid => {\n  const visited = new Set();\n  const n = grid.length;\n  let queue = [[0, 0, "h"]];\n  let step = 0;\n  while (queue.length) {\n    let next = [];\n    for (let i = 0; i < queue.length; ++i) {\n      const key = queue[i].join("-");\n      if (visited.has(key)) continue;\n      visited.add(key);\n      const [x, y, status] = queue[i];\n      if (x === n - 1 && y === n - 2 && status === "h") return step;\n      if (status === "h") {\n        x + 1 < n && grid[x + 1][y] === 0 && grid[x + 1][y + 1] === 0 && next.push([x, y, "v"]) && next.push([x + 1, y, "h"]);\n        y + 2 < n && grid[x][y + 2] === 0 && next.push([x, y + 1, "h"]);\n      } else {\n        y + 1 < n && grid[x][y + 1] === 0 && grid[x + 1][y + 1] === 0 && next.push([x, y, "h"]) && next.push([x, y + 1, "v"]);\n        x + 2 < n && grid[x + 2][y] === 0 && next.push([x + 1, y, "v"]);\n      }\n    }\n    ++step;\n    queue = next;\n  }\n  return -1;\n};\n```
['JavaScript']