✅ Optimized 2 Solutions in CPP || Fastest 🚀 || O(32) Complexity 💡
Intuition\n Bit    Manipulation \n\n# Complexity\n- Time complexity:\nO(32)\n\n- Space complexity:\nO(32)\n\n# Code\nApproach_1 []\n/**\n * @author: cs_balotiya
# Intuition\n$$ Bit$$    $$Manipulation $$\n\n# Complexity\n- Time complexity:\n$$O(32)$$\n\n- Space complexity:\n$$O(32)$$\n\n# Code\n```Approach_1 []\n/**\n * @author: cs_balotiya\n */\nclass Solution {\npublic:\n    // Approach1\n    int minFlips(int a, int b, int c) {\n        int flips = 0;\n        for (int i = 0; i < 32; i++) {\n            // i\'th bit of number a, b, c\n            int bit_a = (a >> i) & 1;\n            int bit_b = (b >> i) & 1;\n            int bit_c = (c >> i) & 1;\n            if ((bit_a | bit_b) != bit_c) {\n                if (bit_c == 1)\n                    flips += 1;\n                else\n                    flips += (bit_a == 1) + (bit_b == 1);\n            }\n        }\n        return flips;\n    }\n};\n```\n```Approach_2 []\n/**\n * @author: cs_balotiya\n */\nclass Solution {\npublic:\n    // Approach2\n    int minFlips(int a, int b, int c) {\n        int flips = 0;\n        bitset<32> bit_a(a);\n        bitset<32> bit_b(b);\n        bitset<32> bit_c(c);\n        for (int i = 0; i < 32; i++) {\n            if ((bit_a[i] | bit_b[i]) != bit_c[i]) {\n                if (bit_c[i] == 1)\n                    flips += 1;\n                else\n                    flips += (bit_a[i] == 1) + (bit_b[i] == 1);\n            }\n        }\n        return flips;\n    }\n};\n```\n
['Bit Manipulation', 'C++']