MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / findComplement

Method findComplement

C++/Number-Complement.cpp:9–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7class Solution {
8public:
9 int findComplement(int num) {
10 int inv = 0, iter = 0;
11 int reminder;
12 while(num) {
13 inv = inv | ((1 - (num % 2))<<iter);
14 num /= 2;
15 iter++;
16 }
17 return inv;
18 }
19};
20

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected