2169. Count Operations to Obtain Zero

Обновлено: 2024-03-12
1 мин
[]

Содержание

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