Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 223 Bytes

476. Number Complement.md

File metadata and controls

14 lines (13 loc) · 223 Bytes
class Solution {
public:
    int findComplement(int num) {
        int mask = 1;
        while (mask <= num && mask > 0) {
            num ^= mask;
            mask <<= 1;
        }
        return num;
    }
};