There are n rooms labeled 0..n-1, all locked except room 0. rooms[i] is a list of keys you obtain by visiting room i, each key opening the room of that number. Starting in room 0, determine whether you can visit all rooms. Return true or false. The input is JSON {rooms}.
Input: JSON {rooms}.
Output: Boolean — true or false.
Input: {"rooms":[[1],[2],[3],[]]}
Output: true
Explanation: Keys chain through all rooms.Input: {"rooms":[[1,3],[3,0,1],[2],[0]]}
Output: false
Explanation: Room 2 is never reachable.Input: {"rooms":[[]]}
Output: true
Explanation: Only room 0.1<=n<=1000