[C++] Brute-Force | 0ms | Worst Approach
\nclass Solution {\npublic:\n    int findComplement(int num) {\n       vector<int> val;\n        while(num > 0){\n            val.push_back(num % 2);\n         
```\nclass Solution {\npublic:\n    int findComplement(int num) {\n       vector<int> val;\n        while(num > 0){\n            val.push_back(num % 2);\n            num /= 2;\n        }\n        reverse(val.begin(), val.end());\n        for(int i = 0; i < val.size(); i++)\n            if(val[i] == 0) val[i] = 1;\n            else val[i] = 0;\n        \n        int ans = 0;\n        long int base = 1;\n        for(int i = val.size()-1; i >= 0; i--){\n            if(val[i] == 1) ans += val[i]*base;\n            base *= 2;\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']