This is a reachability problem. Run DFS starting from room . The DFS will mark every room you can reach by following keys. After DFS completes, check if all rooms are marked visited. If yes, you can visit every room. If no, some rooms are unreachable.
The trick is recognizing this as a graph traversal problem. Rooms are vertices. Keys are directed edges. Reachability from room determines the answer. DFS naturally explores all reachable vertices, making this problem trivial once you see the graph structure.