Skip to content

Commit 2b4f464

Browse files
iamAntimPalAntim-IWPIamShiwangi
committed
Update 1318. Minimum Flips to Make a OR b Equal to c.py
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com> Co-Authored-By: Shiwangi Srivastava <174641070+IamShiwangi@users.noreply.github.com>
1 parent 1eed2a4 commit 2b4f464

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution:
2+
def minFlips(self, a: int, b: int, c: int) -> int:
3+
ans = 0
4+
for i in range(32):
5+
x, y, z = a >> i & 1, b >> i & 1, c >> i & 1
6+
ans += x + y if z == 0 else int(x == 0 and y == 0)
7+
return ans

0 commit comments

Comments
 (0)