Back to problems

Solve Maze and Suffix Problems

Algorithm · Meta · Hard

Problem A: Shortest Path in a Maze with Keys and Doors Since the number of distinct keys is at most 6, we can represent every possible set of collected keys as a bitmask. The BFS state must include the current cell and the current key mask, because reaching the same cell with different keys may unlock different future paths. Complexity: O(rows * cols * 2^K), where K <= 6 is the number of distinct keys. Problem B: Longest Common Suffix Queries The brute-force bottleneck is…

Checking your access…