Toggle Light Bulbs

You are given an array bulbs of integers between 1 and 100.

There are 100 light bulbs numbered from 1 to 100. All of them are switched off initially.

For each element bulbs[i] in the array bulbs:

  • If the bulbs[i]^th light bulb is currently off, switch it on.
  • Otherwise, switch it off.

Return the list of integers denoting the light bulbs that are on in the end, sorted in ascending order. If no bulb is on, return an empty list.

Example 1
Inputbulbs = [10,30,20,10]
Output[20,30]
After toggling bulbs 10, 30, 20, and 10, only the 20th and 30th light bulbs are on.
Example 2
Inputbulbs = [100,100]
Output[]
The 100th light bulb is switched on and then switched off, so no light bulb is on in the end.

Constraints

  • 1 <= bulbs.length <= 100
  • 1 <= bulbs[i] <= 100

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate