MEDIUMasked at 2 companies

Bulb Switcher

A medium-tier problem at 54% community acceptance, tagged with Math, Brainteaser. Reported in interviews at Accenture and 1 others.

Founder's read

Bulb Switcher is the kind of problem that traps candidates who default to simulation. You start thinking about toggling bulbs, tracking state, maybe even building a data structure to track which bulbs are on or off. Then you realize the constraints are huge and your approach grinds to a halt. LinkedIn and Accenture ask this one frequently. The trick isn't about bulbs at all, it's pure math. If you hit this live and blank on the pattern, StealthCoder will surface the mathematical insight in seconds, invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
54%

Companies that ask "Bulb Switcher"

If this hits your live OA

Bulb Switcher is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The trap is obvious: bulb n gets toggled by every divisor it has. Most candidates start coding a simulation or trying to optimize state tracking. What actually works is recognizing that a bulb ends up ON if and only if it has an odd number of divisors. And a number has an odd number of divisors exactly when it's a perfect square. So the answer is just the square root of the input. That's it. No arrays, no toggling, no loops. Once you see it, it's obvious. Before you see it, you're stuck. This is why StealthCoder exists for problems like this: the insight isn't algorithmic complexity or data structure knowledge, it's a pure aha moment that you either catch in prep or don't. The Math and Brainteaser tags tell you upfront to stop thinking like a coder and start thinking like a mathematician.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Bulb Switcher recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Bulb Switcher interview FAQ

Why is this called a brainteaser if it's on LeetCode?+

Because the solution doesn't require coding skill, just pattern recognition. You're not optimizing an algorithm or choosing a data structure. You're seeing that a bulb's final state depends on divisor count, then realizing divisor count is odd only for perfect squares. That's the entire problem.

Is 54% acceptance rate really that bad?+

For a Medium, yes. It means people are either missing the insight entirely or coding a brute force that times out. Once you know the trick, it's one line. Before that, it's a dead end. That gap explains why acceptance is below typical Medium rates.

Do I need to memorize that perfect squares have odd divisors?+

You don't memorize it. You derive it during the problem. Every divisor of n comes in a pair except when a divisor pairs with itself, which happens only for perfect squares. Walking through one example makes this clear. Then the solution is instant.

Will LinkedIn ask follow-ups after I solve it?+

Probably. The main insight is quick, so interviewers often ask you to extend it, handle edge cases, or explain why perfect squares are the key. Be ready to talk through the divisor pairing logic, not just state the answer.

How is this different from other math problems on LeetCode?+

Most math problems still require you to code a solution, even if it's optimized math. This one is unique because the entire solution is a single number you compute. No implementation, no edge cases to code. Just the insight.

Want the actual problem statement? View "Bulb Switcher" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.