C++ beats 96.64%


  • 0
    B
    class Solution {
    public:
        int findComplement(int num) {
            int x = 0x1;
            while (x < num) {
                x <<= 1;
                x |= 0x1;
            }
            return x^num;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.