Skip to content

Commit 6af8974

Browse files
committed
Create README - LeetHub
1 parent f93f3a9 commit 6af8974

File tree

1 file changed

+41
-0
lines changed
  • 2288-count-operations-to-obtain-zero

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<h2><a href="https://leetcode.com/problems/count-operations-to-obtain-zero">2288. Count Operations to Obtain Zero</a></h2><h3>Easy</h3><hr><p>You are given two <strong>non-negative</strong> integers <code>num1</code> and <code>num2</code>.</p>
2+
3+
<p>In one <strong>operation</strong>, if <code>num1 &gt;= num2</code>, you must subtract <code>num2</code> from <code>num1</code>, otherwise subtract <code>num1</code> from <code>num2</code>.</p>
4+
5+
<ul>
6+
<li>For example, if <code>num1 = 5</code> and <code>num2 = 4</code>, subtract <code>num2</code> from <code>num1</code>, thus obtaining <code>num1 = 1</code> and <code>num2 = 4</code>. However, if <code>num1 = 4</code> and <code>num2 = 5</code>, after one operation, <code>num1 = 4</code> and <code>num2 = 1</code>.</li>
7+
</ul>
8+
9+
<p>Return <em>the <strong>number of operations</strong> required to make either</em> <code>num1 = 0</code> <em>or</em> <code>num2 = 0</code>.</p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
14+
<pre>
15+
<strong>Input:</strong> num1 = 2, num2 = 3
16+
<strong>Output:</strong> 3
17+
<strong>Explanation:</strong>
18+
- Operation 1: num1 = 2, num2 = 3. Since num1 &lt; num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.
19+
- Operation 2: num1 = 2, num2 = 1. Since num1 &gt; num2, we subtract num2 from num1.
20+
- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.
21+
Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.
22+
So the total number of operations required is 3.
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> num1 = 10, num2 = 10
29+
<strong>Output:</strong> 1
30+
<strong>Explanation:</strong>
31+
- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.
32+
Now num1 = 0 and num2 = 10. Since num1 == 0, we are done.
33+
So the total number of operations required is 1.
34+
</pre>
35+
36+
<p>&nbsp;</p>
37+
<p><strong>Constraints:</strong></p>
38+
39+
<ul>
40+
<li><code>0 &lt;= num1, num2 &lt;= 10<sup>5</sup></code></li>
41+
</ul>

0 commit comments

Comments
 (0)