simple solution with bitmask beats 100%
Code\ncpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        int ans = 0;\n\n        for (int i = 0; i < 32; i++) {\n            int n_i
# Code\n```cpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        int ans = 0;\n\n        for (int i = 0; i < 32; i++) {\n            int n_ith_bit = (n & (1 << i));\n            int k_ith_bit = (k & (1 << i));\n\n            if ((n_ith_bit ^ k_ith_bit)) {\n                if (n_ith_bit) ans++;\n                else return -1;\n            }\n            \n        }\n\n        return ans;\n    }\n};\n```
['C++']