#1318
Minimum Flips to Make a OR b Equal to c
pupil · 535 · lc medium +28 · verified · 71.9% accepted · 2,139 likes · top 81%
Description
Given three positive integers a, b, and c, a single flip changes one bit in a or b from 0 to 1 or from 1 to 0. Return the minimum number of flips required so that a OR b equals c (using bitwise OR).
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
Code
1
2
3