← All problemsSign in

Switch Game

Chef has $N$ switches which are currently OFF. Chef is sleeping. There are $N$ kids denoted by $k$$i$ ($1 \leq i \leq N$) i.e. $k$$1$, $k$$2$ and so on. $k$$i$ kid comes and changes the state of switches of every $i$th switch. For e.g., if $k$$1$ kid comes, he turns on all the switches, and then if $k$$2$ kid comes, he turns off every second switch as all the switches are ON now. After $k$$N$ kid

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start