Clean code Bit Manipulation Solution with comments
\n\n\nclass Solution {\npublic:\n    //function to check if n has setbit i.e. 1 at position pos\n    bool getBit(int n, int pos){ \n        return (n & 1<<pos);
\n\n```\nclass Solution {\npublic:\n    //function to check if n has setbit i.e. 1 at position pos\n    bool getBit(int n, int pos){ \n        return (n & 1<<pos); \n    }\n    int minFlips(int a, int b, int c) {\n        int ans=0;\n        for(int i =0; i<32; i++){\n            if((getBit(a, i) | getBit(b,i))!=getBit(c, i)){\n                if(getBit(c, i)==1) ans+=1; //since the OR of bits in a and b is 0, so fliping any bit will make the OR = 1\n                else{\n                    //bit in c is zero\n                    if(getBit(a, i) & getBit(b,i)) ans+=2; // if both bits are 1 we need to flip both to make the OR zero so incrementing ans by 2\n                    else ans++; //if one of the bit is one, flip that one\n                }\n            }\n        }\n        return ans;\n    }\n};\n```\n\n![687474703a2f2f692e696d6775722e636f6d2f425972773275612e676966.gif](https://assets.leetcode.com/users/images/33785b4f-7e9b-490e-a26c-f2be12212cbc_1686166271.2359772.gif)\nUpvote if helpful :p
['Bit Manipulation', 'C++']