Shortest Path to Get All Keys

Navigate a grid starting from @ to collect all keys. Lowercase letters are keys, uppercase are locks requiring the corresponding key. Use BFS with a state tracking position and bitmask of collected keys.

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

Shortest Path to Get All Keys

Navigate a grid starting from `@` to collect all keys. Lowercase letters are keys, uppercase are locks requiring the corresponding key. Use BFS with a state tracking position and bitmask of collected keys.