Minimum Flips to Make a OR b Equal to c

Given three integers a, b, and c, return the minimum number of bit flips required so that (a OR b) equals c. Pattern focus: Set/Clear kth Bit. Compare each bit position independently and flip only the positions that are wrong.

Input Format

a, b, c = integers

Output Format

minimum number of bit flips required

Constraints

  • 1 <= input size <= 10^5
  • -10^9 <= numeric values <= 10^9
  • a, b, c must satisfy the format described in inputFormat.

Examples

Example 1:

Input:

a = 2
b = 6
c = 5

Output:

3

Explanation:

Two bits in a/b need adjustment to match c.

Example 2:

Input:

a = 4
b = 2
c = 7

Output:

1

Explanation:

Only one zero bit must be flipped to 1.

Loading...
Minimum Flips to Make a OR b Equal to c