Keys and Rooms
Medium · Graphs · about 10 minutes
Asked at Meta, Google, Apple, Amazon.
There are n rooms numbered 0..n-1; all but room 0 are locked. rooms[i] lists the keys found in room i (each key opens the room with that number). Starting in room 0, return true if you can visit every room.