Leetcode 864. Shortest Path to Get All Keys
Find the minimum number of moves from the start to collect all keys in a grid containing walls and locks (locks are passable only if you have their corresponding key). The core challenge is shortest-path search on an augmented state space (row, column, collected-keys bitmask — k ≤ 6), typically solved with BFS over O(m·n·2^k) states; return -1 if unreachable.
Asked at:
Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid June, 2026
Microsoft
Senior
Simplified to one key/one door. Started with bitmask, iterated through a record/State class, landed on a single 3D boolean visited array as Ramkumar pushed simplification
Hello Interview Premium
Your account is free and you can post anonymously if you choose.