100%✅EXPLAINED✅ Easy C++ Solution
Intuition\nConvert all strings to binary and compare a and b to c with the Bitwise or operator. this means if the numbers you are comparing have at least one 1,
# Intuition\nConvert all strings to binary and compare a and b to c with the Bitwise or operator. this means if the numbers you are comparing have at least one 1, then the result will be a 1.\n# Approach\n\n1. find the first binary number for a(v1) b(v2) and c(v3). we can do this by modding it by 2.\n2. There are 3 cases now. \n     1. v1 and v2 are 1, and v3 is 0. this means we have to convert both 1\'s into 0\'s because if there is at least one 1, the bitwise or operator will return 1. this means there is **2 flips**\n\n     2. v1 or v2 is 1 and v3 is 0. because there is only one 1 out of v1 and v2, we only need **1 flip** to make it 0\n     3. v1 and v2 are 0, and v3 is 1. because we only need at least one 1 to make the bitwise or operator return 1, all we need to do is flip one of the 0\'s into a 1. **1 flip**\n3. there is one final thing that could happen and that is if either a, b, or c is empty, what will we use to compare? we can solve this by setting its corresponding val to 0. this works becuase usually binary numbers have leading whitespace, that is 0\'s, infront of them.\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int minFlips(int a, int b, int c) {\n        int ans = 0;\n        while(a||b||c){\n            int v1 = a?a%2:0, v2 = b?b%2:0, v3 = c?c%2:0;\n            if((v1 == 1 && v2 == 1) && v3 == 0){\n                //case 1\n                ans+=2;\n            } else if((v1 == 1 || v2 == 1) && v3 == 0){\n                //case 2\n                ans+=1;\n            } else if((v1 == 0 && v2 == 0) && v3 == 1){\n                //case 3\n                ans+=1;\n            }\n            a/=2,b/=2,c/=2;\n        }\n        return ans;\n    }\n};\n\n```
['Math', 'Bit Manipulation', 'C++']