Easy - Using bitset STL | Beats 100%
Approach\nCreate a bitset array for both the numbers that contains the binary representation of respective number.\n1. If a bit in n is 1 and a bit at same pos 
# Approach\nCreate a bitset array for both the numbers that contains the binary representation of respective number.\n1. If a bit in n is 1 and a bit at same pos in k is 0, definitely we can change 1 -> 0.\n2. If a bit in n is 0 and a bit at same pos in k is not zero, we return -1 immediately as 0 -> 1 can be performed therefore its impossible to form k from n.\n\n# Complexity\n- Time complexity:\nO(1) as loop runs for constant time of 32 iterations\n\n- Space complexity:\nO(1): each number is represented by 32 bits\n\n# Code\n```\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        if(n == k)\n            return 0;\n\n        bitset<32> n1(n);\n        bitset<32> k1(k);\n        int changes = 0;\n\n        for(int i = 0; i < 32; i++){\n            if(n1[i] == 1 && k1[i] == 0){\n                changes++;\n            }\n            else if(n1[i] == 0 && k1[i] == 1){\n                return -1;\n            }\n        }\n\n        return changes;\n    }\n};\n```
['C++']