Skip to content

#841 - Keys and Rooms

MediumGraphs - DFS
Open on LeetCode

There are n rooms labeled 0 to n - 1. All rooms are locked except room 0. Each room may contain keys to other rooms. Given rooms where rooms[i] is the set of keys in room i, return true if you can visit all rooms.

InputOutput
rooms = [[1],[2],[3],[]]true
rooms = [[1,3],[3,0,1],[2],[0]]false

Released under the MIT License.