we use state (0,0) (0,1) (1,1) to represent we've met bit 1 for 0,1,2 times.
So if the incoming bit is 0, state keeps unchanged while for 1 we come to the next one.
It's brilliant!

I think the last 6 line should be changed to if(digits[i]%3>0). Otherwise, there will be not covered the case that the exceptional number appears in TWICE, such as {1,3,4,1,3,4,5,5,1,3,4}

Thanks for the answer. Although this is not the optimal one (it takes O(32n) complexity because of the outer loop), but it is easy to understand and it is more likely to be the solution that one can quickly come up during an interview.