C++ 0 ms(100 % beat) solution with explanation || No XOR inbuilt used
Approach\n Describe your approach to solving the problem. \nFirst what I did was convert the numbers into binary string form using the function binary.\nAfter t
# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst what I did was convert the numbers into binary string form using the function binary.\nAfter that I checked bit by bit from the last of the binary string numbers to check if a flip is needed or not.\n## **Flips are needed on this basis :**\n1. if z\'s bit is 0, then flip is needed for the bits in x and y if they are 1\n2. if z\'s bit is 1, the only 1 flip is needed if both x and y bits are 0\n3. if z length is over, then treat it as z bit = 0 and goto step 1\n4. if x and y length over, and z length is remaining, then for each z\'s bit = 1 encountered, 1 flip is needed\n\nUsing this minimum flips required are calculated.\n\n# Complexity\n- Time complexity: O(log(max(a,b,c)))\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    string binary(int num){\n        int temp = 1;\n        while(temp<=num){\n            temp*=2;\n        }\n        temp/=2;\n        string ans = "";\n        while(temp>=1){\n            if(temp<=num){\n                num -= temp;\n                ans += "1";\n            }\n            else{\n                ans += "0";\n            }\n            temp/=2;\n        }\n        return ans;\n    }\n\n    int minFlips(int a, int b, int c) {\n        string x = binary(a);\n        string y = binary(b);\n        string z = binary(c);\n        //cout << x << " " << y << " " << z;\n\n        int ans=0;\n        int u=x.length()-1,v=y.length()-1,w=z.length()-1;\n        while(u>=0 && v>=0){\n            if(w<0){\n                if(x[u]==\'1\') ans++;\n                if(y[v]==\'1\') ans++;\n                u--; v--; continue;\n            }\n            else if(z[w]==\'1\'){\n                if(x[u]==\'0\' && y[v]==\'0\') ans++;\n            }\n            else if(z[w]==\'0\'){\n                if(x[u]==\'1\') ans++;\n                if(y[v]==\'1\') ans++;\n            }\n            u--;\n            v--;\n            w--;\n        }\n        while(u>=0){\n            if(w<0){\n                if(x[u]==\'1\') ans++;\n                u--; continue;\n            }\n            else if(z[w]==\'1\' && x[u]==\'0\') ans++;\n            else if(z[w]==\'0\' && x[u]==\'1\') ans++;\n            u--;\n            w--;\n        }\n        while(v>=0){\n            if(w<0){\n                if(y[v]==\'1\') ans++;\n                v--; continue;\n            }\n            else if(z[w]==\'1\' && y[v]==\'0\') ans++;\n            else if(z[w]==\'0\' && y[v]==\'1\') ans++;\n            v--;\n            w--;\n        }\n        while(w>=0){\n            if(z[w]==\'1\') ans++;\n            w--;\n        }\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'C++']