✅[cpp || bit manipulation || 😎🔥O(1) TC || O(1) SC🔥😎]
Intuition \n---\nCase 1 : ith bit in c is on(1)\nAll possibilities:\n\nai 0\nbi 0\nci 1\nOne flip required\n\nai 1\nbi 1\nci 1\nNo flip required\n\nai 0\nbi 1\n
# Intuition \n---\n***Case 1 : i<sup>th</sup> bit in c is on(1)***\n***All possibilities:***\n\na<sub>i</sub> 0\nb<sub>i</sub> 0\nc<sub>i</sub> 1\nOne flip required\n\na<sub>i</sub> 1\nb<sub>i</sub> 1\nc<sub>i</sub> 1\nNo flip required\n\na<sub>i</sub> 0\nb<sub>i</sub> 1\nc<sub>i</sub> 1\nNo flip required\n\na<sub>i</sub> 1\nb<sub>i</sub> 0\nc<sub>i</sub> 1\nNo flip required\n\n---\n\n***Case 2 : i<sup>th</sup> bit in c is off(0)***\n***All possibilities:***\n\na<sub>i</sub> 0\nb<sub>i</sub> 0\nc<sub>i</sub> 0\nNo flip required\n\na<sub>i</sub> 1\nb<sub>i</sub> 1\nc<sub>i</sub> 0\nTwo flip required\n\na<sub>i</sub> 0\nb<sub>i</sub> 1\nc<sub>i</sub> 0\nOne flip required\n\na<sub>i</sub> 1\nb<sub>i</sub> 0\nc<sub>i</sub> 0\nOne flip required\n\n---\n\n# Complexity\n- Time complexity: O(1)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minFlips(int a, int b, int c) {\n        int flip = 0;\n\n        for(int i = 0; i < 32; i++) {\n            bool ai = (a & (1 << i)); // taking the ith bit in a\n            bool bi = (b & (1 << i)); // taking the ith bit in b\n            bool ci = (c & (1 << i)); // taking the ith bit in c\n\n            if(ci) {\n                if(!ai && !bi) flip++;\n            } else {\n                if(ai && bi) flip += 2;\n                else if(ai || bi) flip++;\n            }\n        }\n        return flip;\n    }\n};\n```\n# \uD83D\uDC4D Upvote if it helps\n![UPVOTE](https://i.kym-cdn.com/photos/images/newsfeed/000/676/205/57b.gif)\n
['C++']