We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acf4f3c commit 2869b26Copy full SHA for 2869b26
Single_Number_II.cc
@@ -0,0 +1,15 @@
1
+class Solution {
2
+public:
3
+ int singleNumber(int A[], int n) {
4
+ // Note: The Solution object is instantiated only once and is reused by each test case.
5
+ int One = 0, Two = 0, Three = 0;
6
+ for (int i = 0; i < n; i++) {
7
+ Two |= (One & A[i]);
8
+ One ^= A[i];
9
+ Three = One & Two;
10
+ One &= (~Three);
11
+ Two &= (~Three);
12
+ }
13
+ return (One | Two);
14
15
+};
0 commit comments