Saved Bookmarks
| 1. |
You are given a bulb connected with N switches A switches can be either ON or OFF represented as 1 and 0 respectively The bulb will glow only when there are [N/2] ( where [x] is the smallest integer that is greater than or equal to x) switches ON or set 1 there are Q queries where each query is given a switch position x which is toggled task determine the number of times the bulb changes its state from glowing to not glowing or vice versa notes 1.toggle means changing a switches state from ON to OFF that means from 1 or 0 or OFF to ON that means from 0 to 1 python program given N=3 switches and their initial condition is [1,1,0] there are 2 switches 'ON' hence the bulb will glow query 1: toggle |
| Answer» | |