Search⌘ K
AI Features

Solution: Bulb Switcher

Understand how bulbs toggled in rounds correspond to the number of divisors of their positions. Learn to identify bulbs that remain on by recognizing that only bulbs at perfect square positions stay lit. Explore this solution with a constant-time integer square root calculation.

Statement

You are given n bulbs, all initially turned off. You perform n rounds of toggling operations:

  • In round 11 ...