[InterviewBit] Single Number II

Single Number II

  • Time :
  • Space :
1
2
3
4
5
6
7
8
9
int Solution::singleNumber(const vector<int> &A) {
int a = 0, b = 0;
for(auto n : A) {
a = ~b & (a ^ n);
b = ~a & (b ^ n);
}
return a;
}

Author: Song Hayoung
Link: https://songhayoung.github.io/2022/09/30/PS/interviewbit/single-number-ii/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.