w Explanation||Python/C++ solutions using bitset/bin
Intuition\n Describe your first thoughts on how to solve this problem. \nBit Manipulation uses bitset/bin for C++/Python.\n# Approach\n Describe your approach t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBit Manipulation uses bitset/bin for C++/Python.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code with explanation Beats 100% w 0 ms\n```\nclass Solution {\npublic:\n// Function to calculate the minimum number of flips \n//required to make \'a\' and \'b\' equal to \'c\'\n    int minFlips(int a, int b, int c) { \n// Calculate the bits that need to be flipped \n// in order to make \'a\' or \'b\' equal to \'c\'\n        int xx = (a | b) ^ c;\n\n        // Convert the integer \'xx\' to a bitset of size 32\n        bitset<32> x(xx);\n\n        // Calculate the bits that are 1 \n        // in both \'a\', \'b\', and \'xx\' (common bits)\n        bitset<32> y(a & b & xx);\n\n        // Return the sum of the number of bits \n        //that need to be flipped in \'x\' and \'y\'\n        return x.count() + y.count();\n    }\n};\n\n```\n# Python Code\n```\nclass Solution:\n    def minFlips(self, a: int, b: int, c: int) -> int:\n        xx=(a|b)^c\n        yy=a&b&xx\n        return bin(xx).count(\'1\')+bin(yy).count(\'1\')\n```
['Bit Manipulation', 'C++', 'Python3']