Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make (&nbsp;a OR b == c&nbsp;). (bitwise OR operation).
Flip operation&nbsp;consists of change&nbsp;any&nbsp;single bit 1 to 0 or change the bit 0 to 1&nbsp;in their binary representation.

&nbsp;
Example 1:



Input: a = 2, b = 6, c = 5
Output: 3
Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)

Example 2:

Input: a = 4, b = 2, c = 7
Output: 1


Example 3:

Input: a = 1, b = 2, c = 3
Output: 0


&nbsp;
Constraints:


	1 &lt;= a &lt;= 10^9
	1 &lt;= b&nbsp;&lt;= 10^9
	1 &lt;= c&nbsp;&lt;= 10^9

class Solution:
    def minFlips(self, a: int, b: int, c: int) -> int:
        res = 0
        for i in range(32):
            if (a & 1) | (b & 1) != (c & 1):
                if (c & 1) == 1: # (a & 1) | (b & 1) should be == 1 ; so changing any of a, b we can get 1
                    res += 1
                else: # (a & 1) | (b & 1) should be == 0 ; is (a & 1) == 1 and (b & 1) == 1 we need to change both to 0 so res += 1; if any of them is 1 then change only 1 i.e. res += 1
                    res += (a & 1) + (b & 1)
            a, b, c = a>>1, b>>1, c>>1 # right-shift by 1

        return res

# Time: O(1)
# Space: O(1)
class Solution {
    public int minFlips(int a, int b, int c) {
        int j=-1;
        int x=a|b;
        int count=0;
        while(c!=0 || x!=0){
            j++;
            int aa=x%2;
            int bb=c%2;
            if(aa==0 && bb==1)count++;
            else if(aa==1 && bb==0) count+=funcount(j,a,b);
            x=x>>1;
            c=c>>1;
        }
        return count;
    }
    public static int funcount(int shift,int a,int b){
        int cc=0;
        int mask=1<<shift;
        int b1=a&mask;
        int b2=b&mask;
        if(b1!=0)cc++;
        if(b2!=0)cc++;
        return cc;
    }
}```
class Solution {
public:
    int minFlips(int a, int b, int c) {
        int changeBits = 0;

        for(int i=0; i<32; i++){
            int lastBitA = 0;
            int lastBitB = 0;
            int lastBitC = 0;
            if(((a >> i) & 1) == 1){
                lastBitA = 1;
            }
            if (((b >> i) & 1) == 1){
                lastBitB = 1;
            }
            if (((c >> i) & 1) == 1){
                lastBitC = 1;
            }
            if(lastBitC == 1){
                if(lastBitA == 0 & lastBitB == 0){
                    changeBits++;
                }
            }
            else{
                if(lastBitA == 1 || lastBitB == 1){
                    if(lastBitA == 1){
                        changeBits++;
                    }
                    if(lastBitB == 1){
                        changeBits++;
                    }
                }
            }
        }
        return changeBits;
    }
};
var minFlips = function(a, b, c) {
    let ans = 0;
    for(let bit = 0; bit < 32; bit++) {
        let bit_a = (a >> bit)&1, bit_b = (b >> bit)&1, bit_c = (c >> bit)&1;
        if(bit_c !== (bit_a | bit_b)) {
            if(bit_c === 1) { //a b will be 0 0
                ans += 1;
            } else { //a b -> 0 1 -> 1 0 -> 1 1
                ans += (bit_a + bit_b === 2 ? 2 : 1);
            }
        }
    }
    return ans;
};
Minimum Flips to Make a OR b Equal to c