Faster method than given in the solution


int Solution::bulbs(vector &A) {
int cnt = 0;
for(int i=0; i<A.size(); i++){
cnt += !((cnt%2)^A[i]);
return cnt;


The answer given in the solution and yours both are having same linear time complexity.


there is no difference in your solution and given solution :slight_smile:


don’t use modulo operator, use bit manipulation method to make it faster.


Congrats, if someone plugged in a list of size 3 billion, yours would be 0.000001 seconds faster than everyone else’s. It would also take someone else looking at your code 5 more seconds to understand it :+1: