Given a line of light bulbs, determine which bulbs are on after a sequence of toggle operations that affect many positions at once.
You are given a row of light bulbs, initially all turned off. A series of toggle operations is performed on the bulbs. Each operation changes the state of one or more bulbs from off to on or from on to off.
Your task is to determine the final state of the bulbs after all operations have been applied.
This problem is typically solved by tracking how many times each bulb is toggled and using parity or a difference-style approach instead of simulating every toggle one by one when possible.
Example 1
Input
n = 5 operations = [[1, 3], [2, 5]]
Output
[1, 0, 0, 1, 1]
Explanation
Starting with 00000:
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.