Mid/SeniorBit Manipulation
Minimum Flips to Make a OR b Equal to c
Given 3 positive numbers a, b, and c, return the minimum number of flips required in some bits of a and b to make (a OR b == c).
A flip operation consists of changing any single bit from 1 to 0 or changing a bit from 0 to 1 in their binary representation.
Example 1
Input
a = 2, b = 6, c = 5Output
3After flips,
a = 1 and b = 4, so (a OR b == c).Example 2
Input
a = 4, b = 2, c = 7Output
1One bit flip is enough to make (
a OR b == c).Constraints
- 1 <= a <= 10^9
- 1 <= b <= 10^9
- 1 <= c <= 10^9