C++ Readable.
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have to transform a number n into another number k with the following rules:\n\n You
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to transform a number n into another number k with the following rules:\n\n* You can change a bit from 1 to 0.\n* You **cannot** change a bit from 0 to 1.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize a counter count to 0 to track the number of changes needed.\n2. Loop through each bit position from 0 to 31:\n   * Check if the i-th bit of n is set (1) or not (0).\n   * Check if the i-th bit of k is set (1) or not (0).\n3. Evaluate the bit positions:\n    * If the i-th bit of n is not set and the i-th bit of k is set, return -1 (since 0 to 1 is not allowed).\n    * If the i-th bit of n is set and the i-th bit of k is not-set, increment count by 1 (we need to change this bit from 1 to 0).\n    * If both bits are the same, do nothing.\n4. Return the count after evaluating all bits.\n\n# Complexity\n- Time complexity: O(32) is constant time.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n//1 to 0 is allowed\n//0 to 1 is not allowed\n\n    int minChanges(int n, int k) {\n        int count = 0;\n        for(int i=0; i<32; i++){\n\n            bool isSetN = false, isSetK = false;\n            \n            //checking ith bit\n            if((1<<i) & n) isSetN = true;\n            if((1<<i) & k) isSetK = true;\n\n            //if N has a bit not set i.e. 0 and K has that bit set i.e. 1\n            //since 0 to 1 is not allowed, return -1;\n            if(!isSetN && isSetK) return -1;\n            else if(isSetN && !isSetK) count++;\n        }\n        return count;\n    }\n};\n```
['Bit Manipulation', 'C++']