Count Operations to Obtain Zero
You are given two non-negative integers num1 and num2.
In one operation, if num1 >= num2, you must subtract num2 from num1; otherwise, subtract num1 from num2.
Return the number of operations required to make either num1 = 0 or num2 = 0.
Example 1
Input
num1 = 2, num2 = 3Output
3After three operations,
num1 becomes 0, so the total number of operations required is 3.Example 2
Input
num1 = 10, num2 = 10Output
1Since
num1 == num2, one operation subtracts num2 from num1, making num1 equal to 0.Constraints
- 0 <= num1, num2 <= 10^5