There are 100 switches in a room operating 100 bulbs. At iteration '0' all switches are OFF. For every iteration 'i', all switches that are multiples of 'i' are toggled (turn OFF if ON, turn ON if OFF).
You need to find the state of the 'k'th switch/bulb (1
<=100) after the 'i' th iterationExpected O(1) time and space complexity.
0 comments:
Post a Comment