Leetcode Problem 2169. Count Operations to Obtain Zero
2169. Count Operations to Obtain Zero
Leetcode Solutions
Iterative Subtraction Approach
Initialize a counter to keep track of the number of operations performed.
While both num1 and num2 are greater than zero:
a. If num1 is greater than or equal to num2, subtract num2 from num1.
b. Otherwise, subtract num1 from num2.
c. Increment the counter by one.
Return the counter as the result, which represents the number of operations required to make either num1 or num2 equal to zero.