int Solution::bulbs(vector &A) {

int cnt = 0;

for(int i=0; i<A.size(); i++){

cnt += !((cnt%2)^A[i]);

}

return cnt;

}

# Faster method than given in the solution

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

**mang0**#5

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