[faster than 100.00%][c++][easy understanding]
\n//1.\nclass Solution {\npublic:\n    int bitwiseComplement(int N) {\n        if(N==0) \n\t\t   return 1;\n        int res=0,k=1;\n        while(N){\n         
```\n//1.\nclass Solution {\npublic:\n    int bitwiseComplement(int N) {\n        if(N==0) \n\t\t   return 1;\n        int res=0,k=1;\n        while(N){\n            int d=N%2; //finding a bit\n            res+=(d==1?0:1)*k;  //complement of bit and complement\n            N/=2; \n            k*=2;\n        }\n        return res;\n        \n    }\n};\n//2.\nclass Solution {\npublic:\n    int bitwiseComplement(int N) {\n         if(N==0)\n            return 1;\n        int x=N;\n        int highval=0;\n\t\t// finding highest value of bit size of N\n        while(N){\n            highval=highval*2+1;\n            N/=2;\n        }\n        return highval-x;\n    }\n};\n```
['C', 'C++']