Minimum One Bit Operations to Make Integers Zero LeetCode solution in C++

1
class Solution {
2
public:
3
int minimumOneBitOperations(int n) {
4
int output = 0;
5

6
while (n > 0) {
7
output ^= n;
8
n = n >> 1;
9
}
10

11
return output;
12
}
13
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0