JAVA(Sol for Beginner)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n    Bitwise Operation Approach\n     (2) String Conversion and Bit Compar
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n    Bitwise Operation Approach\n    <!-- (2) String Conversion and Bit Comparison Approach -->\n\n# Complexity\n- Time complexity:\n    O(logn)\n    <!-- (2) O(max(logn,logk)) -->\n\n\n# Code\n```\nclass Solution {\n    public int minChanges(int n, int k) {\n        if ((n | k) != n) {\n            return -1;\n        }\n        int changes = 0;\n        while (n > 0) {\n            if ((n & 1) == 1 && (k & 1) == 0) {\n                changes++;\n            }\n            n >>= 1;\n            k >>= 1;\n        }\n        return changes;\n    }\n}\n// (2)\n// public int minChanges(int n, int k) {\n//     String binaryn = Integer.toBinaryString(n);\n//     String binaryk = Integer.toBinaryString(k);\n\n//     if (binaryk.length() > binaryn.length()) {\n//         return -1;\n//     }\n\n//     int maxLength = Math.max(binaryn.length(), binaryk.length());\n//     binaryn = String.format("%" + maxLength + "s", binaryn).replace(\' \', \'0\');\n//     binaryk = String.format("%" + maxLength + "s", binaryk).replace(\' \', \'0\');\n\n//     int changes = 0;\n//     for (int i = 0; i < maxLength; i++) {\n//         char bn = binaryn.charAt(i);\n//         char bk = binaryk.charAt(i);\n\n//         if (bk == \'1\' && bn == \'0\') {\n//             return -1;\n//         } else if (bn == \'1\' && bk == \'0\') {\n//             changes++;\n//         }\n//     }\n\n//     return changes;\n// }\n```
['Java']