Shortest path to collect all keys

0
Remix

A grid has walls, a start cell, keys (lowercase letters) and locks (the matching uppercase letters). A lock can only be passed once you hold its key. Return the fewest steps to collect every key, or -1. Run a breadth-first search over states made of the position and the set of keys held, stored as a bitmask.

AirbnbCodingLast asked Aug 2025
No answer yet. Write the first one; the best answer gets endorsed.