NiuNiu MaTe
Feb 15, 2022 · Fundamentals
Why Do Only Perfect Squares Stay Lit? Solving the Bulb Switch Puzzle
The article explains the classic bulb‑switch problem, showing how toggling bulbs in successive rounds leads to only those positioned at perfect‑square indices remaining on, derives the mathematical reasoning behind the pattern, and presents a concise O(1) solution using the integer square‑root of n.
LeetCodealgorithmbulb-switch
0 likes · 7 min read
