Solving Shortest Path to Get All Keys in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

We start at the starting point, and one move consists of walking one space in one of the 4 cardinal directions. We cannot walk outside the grid, or walk into a wall. If we walk over a key, we pick it up. We can't walk over a lock unless we have the corresponding key.

Example 1:

Input: ["@.a.#","###.#","b.A.B"]
Output: 8

Example 2:

Input: ["@..aA","..B#.","....b"]
Output: 6

Note:

  1. 1 <= grid.length <= 30
  2. 1 <= grid[0].length <= 30

See the full details of the problem Shortest Path to Get All Keys at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go