✅ C++ ✅ Java ✅ Python Solution 🔥Beats 100%🔥|| 0ms Run time ✅
Linkedin Profile (https://linkedin.com/in/ayush-kumar-a276a124a)\n//-------------> \uD83D\uDC7B Pls Upvote if it is helpful for You \uD83D\uDC7B <--------------
- Linkedin Profile (https://linkedin.com/in/ayush-kumar-a276a124a)\n//-------------> \uD83D\uDC7B Pls Upvote if it is helpful for You \uD83D\uDC7B <-----------------//\n\n# Complexity\n- Space complexity: ---> O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# C++ Code\n```class Solution {\npublic:\n    int minFlips(int a, int b, int c) {\n        int ans=0;\n        while(a||b||c){\n            int x1=a&1;\n            int x2=b&1;\n            int x3=c&1;\n            if((x1|x2)!=x3){\n                if(x1&x2)   ans+=2;\n                else ans+=1;\n            }\n            a=a>>1;\n            b=b>>1;\n            c=c>>1;\n        }\n        return ans;\n    }\n};\n```\n# Python Code\n```class Solution:\n    def minFlips(self, a, b, c):\n        ans = 0\n        while a or b or c:\n            x1 = a & 1\n            x2 = b & 1\n            x3 = c & 1\n            if (x1 | x2) != x3:\n                if x1 & x2:\n                    ans += 2\n                else:\n                    ans += 1\n            a = a >> 1\n            b = b >> 1\n            c = c >> 1\n        return ans\n\n```\n# Java Code \n```\nclass Solution {\n    public int minFlips(int a, int b, int c) {\n        int ans = 0;\n        while (a != 0 || b != 0 || c != 0) {\n            int x1 = a & 1;\n            int x2 = b & 1;\n            int x3 = c & 1;\n            if ((x1 | x2) != x3) {\n                if ((x1 & x2) == 1)\n                    ans += 2;\n                else\n                    ans += 1;\n            }\n            a = a >> 1;\n            b = b >> 1;\n            c = c >> 1;\n        }\n        return ans;\n    }\n}\n\n```\n\uD83D\uDC7B IF YOU LIKE THE SOLUTION THEN PLEASE UPVOTE MY SOLUTION BECAUSE IT GIVES ME MOTIVATION TO REGULARLY POST THE SOLUTION\uD83D\uDC7B*\n\n![image.png](https://assets.leetcode.com/users/images/808ce812-ef58-4889-9d68-6c3a66620ff1_1686095947.3712385.png)
['Bit Manipulation', 'Bitmask', 'Python', 'C++', 'Java']