diff --git a/Minimum One Bit Operations to Make Integers Zero.py b/Minimum One Bit Operations to Make Integers Zero.py new file mode 100644 index 00000000..92389abe --- /dev/null +++ b/Minimum One Bit Operations to Make Integers Zero.py @@ -0,0 +1,7 @@ +class Solution: + def minimumOneBitOperations(self, n: int) -> int: + res = 0 + while n: + res = -res - (n ^ (n - 1)) + n &= n - 1 + return abs(res)