Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Treat each room as a node and each key as a directed edge. DFS/BFS through keys and count visited nodes.
All possible moves are key edges. If every room is eventually visited, then keys connect the graph from node 0 to all nodes.
Updated Feb 2026