We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think everyone including editorial did not consider the fact the When some button is pressed, all the bulbs at a distance from bulb will be toggled(off->on, on->off).
I think everyone (inlucding me ) did not takethis into account. for example
if array is 0 1 2 3 4 5 6 7 8 and K is 2, with brute force, when you turn off the light at 0th index, it will stop switches until index 2 and next switch to turn off is the one at index 5 which will turn off all the switched upto index 7 and now if you try to turn off 8, it will turn on 6 & 7.
Is my understanding correct? Am I missing something here?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Turn Off the Lights
You are viewing a single comment's thread. Return to all comments →
I think everyone including editorial did not consider the fact the When some button is pressed, all the bulbs at a distance from bulb will be toggled(off->on, on->off).
I think everyone (inlucding me ) did not takethis into account. for example
if array is 0 1 2 3 4 5 6 7 8 and K is 2, with brute force, when you turn off the light at 0th index, it will stop switches until index 2 and next switch to turn off is the one at index 5 which will turn off all the switched upto index 7 and now if you try to turn off 8, it will turn on 6 & 7.
Is my understanding correct? Am I missing something here?