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:
bulbs[i]th light bulb is currently off, switch it on.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:
Input: bulbs = [10,30,20,10]
Output: [20,30]
Explanation:
bulbs[0] = 10th light bulb is currently off. We switch it on.bulbs[1] = 30th light bulb is currently off. We switch it on.bulbs[2] = 20th light bulb is currently off. We switch it on.bulbs[3] = 10th light bulb is currently on. We switch it off.Example 2:
Input: bulbs = [100,100]
Output: []
Explanation:
bulbs[0] = 100th light bulb is currently off. We switch it on.bulbs[1] = 100th light bulb is currently on. We switch it off.
Constraints:
1 <= bulbs.length <= 1001 <= bulbs[i] <= 100Solutions for this problem are being prepared.
Try solving it yourselfPractice Toggle Light Bulbs with our built-in code editor and test cases.
Practice on FleetCodePractice this problem
Open in Editor