Skip to content

Commit 614973b

Browse files
committed
Time: 28 ms (96.55%), Space: 17.7 MB (50.31%) - LeetHub
1 parent 37e76e0 commit 614973b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution:
2+
def minFlips(self, a: int, b: int, c: int) -> int:
3+
flips = 0
4+
while a > 0 or b > 0 or c > 0:
5+
bit_a = a & 1
6+
bit_b = b & 1
7+
bit_c = c & 1
8+
9+
if bit_c == 0:
10+
flips += (bit_a + bit_b)
11+
else:
12+
if bit_a == 0 and bit_b == 0:
13+
flips += 1
14+
15+
a >>= 1
16+
b >>= 1
17+
c >>= 1
18+
19+
return flips

0 commit comments

Comments
 (0)