Given positive integers a, b, c: return the minimum number of bit flips in a or b to make a OR b == c.

Input: a=2, b=6, c=5 → Output: 3Input: a=4, b=2, c=7 → Output: 1

Check each bit position: if c-bit is 1, we need at least one of a-bit or b-bit to be 1 (cost=1 flip if both are 0). If c-bit is 0, both a-bit and b-bit must be 0 (cost = number of 1s among them).

class Solution { public int minFlips(int a, int b, int c) { int flips = 0; for (int i = 0; i < 32; i++) { int ba = (a >> i) & 1, bb = (b >> i) & 1, bc = (c >> i) & 1; if (bc == 1) { if (ba == 0 && bb == 0) flips++; } else { flips += ba + bb; } } return flips; } }