Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 71616ed

Browse files
committed
created solution for problem69
1 parent e6d685b commit 71616ed

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

problem69/Solution.py

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 c > 0:
5+
if (c&1) == 0:
6+
flips += (a&1) + (b&1)
7+
elif ((a&1) | (b&1)) == 0:
8+
flips += 1
9+
10+
c >>= 1
11+
a >>= 1
12+
b >>= 1
13+
14+
while a > 0 or b > 0:
15+
flips += (a&1) + (b&1)
16+
a >>= 1
17+
b >>= 1
18+
19+
return flips

0 commit comments

Comments
 (0)