C++ | bit manipulation approach Explained + Code
Approach- \n1) If the c\'s bit is 0 and \n case-1: a\'s and b\'s bit are 1 then need 2 flips\n case-2: one of them is 1 then need only 1 flip\n\n2) If the c\'s 
# Approach- \n1) If the c\'s bit is 0 and \n case-1: a\'s and b\'s bit are 1 then need 2 flips\n case-2: one of them is 1 then need only 1 flip\n\n2) If the c\'s bit is 1 then \n case-1: if on a and b both are 0 then need 1 flip \n\n\n# Full explanation-\n[https://youtu.be/hIiBHXN8HXE]()\n\n\n# Code\n```\nclass Solution {\npublic:\n    int minFlips(int a, int b, int c) {\n        int ans = 0;\n\n        while(a || b || c){\n            int bitA = a&1;\n            int bitB = b&1;\n            int bitC = c&1;\n\n            if(bitC == 0){\n                if(bitA==1 && bitB==1) ans+=2;\n                else if(bitA || bitB) ans+= 1;\n            }\n\n            else if(bitC ==1 && bitA==0 && bitB==0){\n                ans+= 1;\n            }\n\n            a>>= 1;\n            b>>= 1;\n            c>>= 1;\n        }\n\n        return ans;\n    }\n};\n```\n\nPlease do upvote if you like the solution:)
['Bit Manipulation', 'C++']