[JAVA] Explained Solution!
convert integer to binary string.\n2. if len(binary(k)) > len(binary(n)) return -1, means we have more position as 1 in k for which n will be 0. EX: \n    k = 1
1. convert integer to binary string.\n2. if len(binary(k)) > len(binary(n)) return -1, means we have more position as 1 in k for which n will be 0. EX: \n    k = 10101\n    n =  1000\n3. iterate on reverse of both strings to len of n, check if n ith position is 1 and k ith position is 0, if found, increase the result by 1 else return -1;\n4. for all remaining values in n, if ith position is 1, increase the result.\n\n\n\n# Code\n```\nclass Solution {\n    public int minChanges(int n, int k) {\n        int res = 0;\n        String s1 = new StringBuilder(Integer.toBinaryString(n)).reverse().toString();\n        String s2 = new StringBuilder(Integer.toBinaryString(k)).reverse().toString();\n        if(s2.length() > s1.length()) return -1;\n        for(int i = 0; i < s1.length(); i++) {\n            if(i < s2.length()) {\n                if(s2.charAt(i) != s1.charAt(i)) {\n                    if(s2.charAt(i) == \'1\') return -1;\n                    res++;\n                }\n            } else {\n                if(s1.charAt(i) == \'1\') res++;\n            }\n        }\n        return res;\n    }\n}\n```
['Java']