2169. Count Operations to Obtain Zero

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2169

class Solution:
    def countOperations(self, num1: int, num2: int) -> int:
        res = 0
        while num1 and num2:
            if num1 >= num2:
                num1, num2 = num2, num1
            num2 -= num1
            res += 1
        return res