 All Problems
Keys and Rooms
medium
graphs
dfs
bfs
amazon
google

There are n rooms (0 to n-1). Room 0 is unlocked. Each room has a set of keys to other rooms. Return true if you can visit all rooms.

Example 1:

Input:
4
1
2
3
(empty)
Output: true

Input format: Line 1: n. Next n lines: space-separated keys in that room (or empty line).

Output format: true or false.

Run to check your code against the sample cases, or submit to run every case