On campus coding round was held and two coding ques was to be solved in 2 hours.
Question 1 : there are switches that can be controlled by a remote , n such switches are connected in series and at the end of there is a bulb , the remote has a button that toggle the state of the switch (on to off and vice versa) , but the remote only works in switches which have a electric connection to them , A switch is connected when when all the previous switches are turned ON, and the bulb is on when all the switches are ON , At first all the switches are off and only the first switch is connected ,
Input- N (number of switches ) ,1 < N < 30
K(number of times the button is pressed) 1 < k < 10^7 output – 1 (if the bulb is on) , -1 (if it’s not).
Question 2 : there are N employee sitting in consecutive cubicles , we have to send a few of them to onsite , but each time we send one employee onsite , his cubicle becomes empty , now the other employees from both side of that empty cubicle stops working until they are given a gift .
the gifts are given in both sides of the empty cubicle until we reach the end or found another cubicle ,
Input – number of cubicle , and index numbers of people to be sent
output- min number of gifts needed