Ques1:
N rooms numbered from 0 to n-1 initially only 0th room is unlocked. Rooms will have keys for any rooms. We need to find if we can visit all the rooms.
Input: [[1], [2], [3], []]
output : true
We start in room 0 and pick up key 1.
We then go in room 1 and pick up key 2.
We then go in room 2 and pick up key 3.
We then go in room 3. Since we were able to go to every room, we return true.
Input: [[1,3], [3,0,1], [2], [0]]
Output: false
We can't enter room with number 2
0 -> 1, 3
1 -> 0, 1, 3
2 -> 2
3 -> 0
Ques2:
You are given location of n number of houses on a straight line and k street lights.
The street light has a power P value.
If a street light is located at location x, it will spread light from [x-P , x+P]
You need to find the minimum value of K so that we can light all the houses.
Example1:
houses[] = [1,2,3,4,5]
P = 1
output = 2
Example2:
houses[] = [7,2,4,6,5,9,12,11]
P = 2
output = 3