Skip to content

Commit b3ce4e2

Browse files
Create README - LeetHub
1 parent 5007702 commit b3ce4e2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/find-the-duplicate-number/">287. Find the Duplicate Number</a></h2><h3>Medium</h3><hr><div><p>Given an array of integers <code>nums</code> containing&nbsp;<code>n + 1</code> integers where each integer is in the range <code>[1, n]</code> inclusive.</p>
2+
3+
<p>There is only <strong>one repeated number</strong> in <code>nums</code>, return <em>this&nbsp;repeated&nbsp;number</em>.</p>
4+
5+
<p>You must solve the problem <strong>without</strong> modifying the array <code>nums</code>&nbsp;and uses only constant extra space.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre><strong>Input:</strong> nums = [1,3,4,2,2]
11+
<strong>Output:</strong> 2
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre><strong>Input:</strong> nums = [3,1,3,4,2]
17+
<strong>Output:</strong> 3
18+
</pre>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Constraints:</strong></p>
22+
23+
<ul>
24+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
25+
<li><code>nums.length == n + 1</code></li>
26+
<li><code>1 &lt;= nums[i] &lt;= n</code></li>
27+
<li>All the integers in <code>nums</code> appear only <strong>once</strong> except for <strong>precisely one integer</strong> which appears <strong>two or more</strong> times.</li>
28+
</ul>
29+
30+
<p>&nbsp;</p>
31+
<p><b>Follow up:</b></p>
32+
33+
<ul>
34+
<li>How can we prove that at least one duplicate number must exist in <code>nums</code>?</li>
35+
<li>Can you solve the problem in linear runtime complexity?</li>
36+
</ul>
37+
</div>

0 commit comments

Comments
 (0)