Beat 100% with c++
Intuition\nUsing bit manipulation to solve this problem.\n\n# Approach\nThis solution uses bit manipulation to determine the minimum number of changes needed to
# Intuition\nUsing bit manipulation to solve this problem.\n\n# Approach\nThis solution uses bit manipulation to determine the minimum number of changes needed to make integer n equal to integer k by only turning 1 bits in n to 0. Here\'s the approach:\n\n1. Bitwise OR Check: First, it checks if k can be derived from n by turning some of n\'s 1 bits to 0. If k has any 1 bits that n does not, it\u2019s impossible to make n equal to k, so we return -1. This is done by checking (n | k) != n.\n\n2. XOR Operation: If k can be obtained from n, we compute n ^ k, which highlights the differing bits between n and k.\n\n3. Counting Set Bits: Finally, we count the number of 1 bits in the result of n ^ k, representing the positions where n has 1s that need to be turned to 0s to match k.\n\nThe time complexity is O(log n) due to the bit counting, and the space complexity is O(1) since only a few variables are used.\n\n# Complexity\n- Time complexity:\n    O(log n)\n\n- Space complexity:\n    O(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) \n    {\n        if ((n | k) != n) \n        {\n            return -1;\n        }\n\n        int xored = n ^ k;\n        int count = 0;\n        while(xored)\n        {\n            if(xored & 1)\n            {\n                count++;\n            }\n            xored = xored >> 1; \n        }\n        return count;\n    }\n};\n```
['C++']