Most Optimal Solution  (Bitwise Operations C++)
Intuition\n Describe your first thoughts on how to solve this problem. \nStraight forward thinking, check last bit if N (use n & 1) and check adj bit in K if we
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStraight forward thinking, check last bit if N (use n & 1) and check adj bit in K if we get 1 in n we can toggle to 0 if the need persist, increment count else if we get 0 return -1 as 0 cant be changed to 1.\n\nOptimized thinking : bit difference can be found using xor operation (n ^ k), rather than traversing in diff(xor diff) bit by bit (log n TC) we can only check the set bits in diff ! and check the corrosponding bit of n \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nTC better than log N, where N is bit difference ! \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        int diff = n ^ k;\n        unsigned int cnt = 0;\n        \n        while(diff)\n        {\n            // For every set bit in diff, check the adj bit in n\n            unsigned int mask = diff & (-diff);\n\n            // int ans = n & \n            // We can only change 1s to 0 and not 0s to 1, if at mask location \n            if((n & mask) == 0) return -1;\n            else ++cnt;\n\n            // unset the last set bit\n            diff &= (diff - 1);\n        }\n\n        return cnt;\n    }\n};\n```
['Bit Manipulation', 'C++']