✅Easy and simple solution ✅Explanation ✅Brute froce approach ✅clean code
Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F\nFoll
***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***<br>\n**Follow me on LinkeDin [[click Here](https://www.linkedin.com/in/ayushluthra62/)]**\n\n\n# Approach / Pseudo code\n1. we will find the bits of both n and k and store it in tempraory  vector\n2. we will add zeros at the start so they both have same size \n3. now check if they have same bit or not \n4. if not check temp1[currbit] ==1 then we can convert it 0 otherwise return -1 because we can\'t make 0 to 1 \n5. else increment count\n6. return count\n\n\n# Complexity\n- Time complexity:\nO(Max(N,K)) \n\n- Space complexity:\nO(Max(N,K)) \n# Code\n```\nclass Solution {\npublic: \n\n    // storing bit in tempraory vector \n    void solve(vector<int>& temp,int n){\n        while(n>0){\n            temp.push_back(n%2);\n            n=n/2;\n        }\n        reverse(temp.begin(),temp.end());\n    }\n    int minChanges(int n, int k) {\n        if(n==k) return 0;\n        \n        vector<int>temp1,temp2;\n        \n        solve(temp1,n);\n        solve(temp2,k);\n        \n        // adding zeros in front of temp2\n        if(temp1.size() > temp2.size()){\n            int j = temp2.size();\n            reverse(temp2.begin(),temp2.end());\n            while(j<temp1.size()) {\n                temp2.push_back(0);\n                j++;\n            }\n              reverse(temp2.begin(),temp2.end());\n        }\n\n        // adding zeros in front of temp1 \n        if(temp2.size()>temp1.size()){\n            int j = temp1.size();\n            reverse(temp1.begin(),temp1.end());\n            while(j<temp2.size()) {\n                temp1.push_back(0);\n                j++;\n            }\n              reverse(temp1.begin(),temp1.end());\n        }\n        \n        \n      \n        \n        int count =0;\n        for(int i=0;i<temp1.size();i++){\n            if(temp1[i] != temp2[i] ){\n                if(temp1[i]==0) return -1;\n                else count++;\n            } \n        }\n        return count;\n        \n    }\n};\n```\n***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***<br>\n**Follow me on LinkeDin [[click Here](https://www.linkedin.com/in/ayushluthra62/)]**\n
['Array', 'C++']