2
def shortestPathAllKeys(self, grid: List[str]) -> int:16
elif grid[i][j].islower():20
for _ in range(len(q)):21
curr_x, curr_y, keys = q.popleft()22
if (curr_x, curr_y, keys) in visited:25
visited.add((curr_x, curr_y, keys))27
if len(keys) == keyCt:30
for x, y in ((0, 1), (1, 0), (-1, 0), (0, -1)):38
or grid[nx][ny] == "#"39
or (nx, ny, keys) in visited44
if curr in "abcdef" and curr not in keys:45
q.append((nx, ny, keys + curr))46
elif curr.isupper() and curr.lower() not in keys:49
q.append((nx, ny, keys))