Easy&Detailed Explanations, Beats 100%
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe just have to check two cases here when we have to flip the bit_:\n\n1- When the bit in c equals to 1 and both bit in a and b equals to 0 we flip the bit of either a or b to get the same bit as c.\n\n2- When the bit in c equals to 0 then we can only get that when both bits in a and b are zero so we have to put just 2 if cases to check them.\n\n# Complexity\n- Time complexity:O(n)\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```java []\nclass Solution {\n    public int minFlips(int a, int b, int c) {\n        int flips=0;\n        while(a>0 || b>0 || c>0){\n            if((c&1)==1){\n                if((a&1)==0 && (b&1)==0) flips++;\n            }\n            else{\n                if((a&1)==1) flips++;\n                if((b&1)==1) flips++;\n            }\n            a>>=1;\n            b>>=1;\n            c>>=1;\n        }\n        return flips;\n    }\n}\n```
['Bit Manipulation', 'C++', 'Java']