Back to course home
0% completed
Keys and Rooms (medium)
Problem Statement
You are given n
rooms labeled from 0
to n-1
. Initially, you can only enter inside the room 0
, and all other rooms are locked.
However, you cannot enter a locked room without having its key.
Each room may contain a set of keys, each key opens a specific room. Each key has a number n
on it, which opens up n<sup>th</sup> room starting from 0
, and you can take all of them with you to unlock the other rooms.
Given an array rooms
where rooms[i]
is the set of keys that you can obtain if you visited room i
, return true
if you can visit all the rooms
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible