Skip to content

Commit 9a2d8d3

Browse files
committed
Create README - LeetHub
1 parent 645c6e7 commit 9a2d8d3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

delete-and-earn/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<h2>740. Delete and Earn</h2><h3>Medium</h3><hr><div><p>Given an array <code>nums</code> of integers, you can perform operations on the array.</p>
2+
3+
<p>In each operation, you pick any <code>nums[i]</code> and delete it to earn <code>nums[i]</code> points. After, you must delete <b>every</b> element equal to <code>nums[i] - 1</code> or <code>nums[i] + 1</code>.</p>
4+
5+
<p>You start with <code>0</code> points. Return the maximum number of points you can earn by applying such operations.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong>Example 1:</strong></p>
9+
10+
<pre><strong>Input:</strong> nums = [3,4,2]
11+
<strong>Output:</strong> 6
12+
<strong>Explanation:</strong> Delete 4 to earn 4 points, consequently 3 is also deleted.
13+
Then, delete 2 to earn 2 points.
14+
6 total points are earned.
15+
</pre>
16+
17+
<p><strong>Example 2:</strong></p>
18+
19+
<pre><strong>Input:</strong> nums = [2,2,3,3,3,4]
20+
<strong>Output:</strong> 9
21+
<strong>Explanation:</strong> Delete 3 to earn 3 points, deleting both 2's and the 4.
22+
Then, delete 3 again to earn 3 points, and 3 again to earn 3 points.
23+
9 total points are earned.
24+
</pre>
25+
26+
<p>&nbsp;</p>
27+
<p><strong>Constraints:</strong></p>
28+
29+
<ul>
30+
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
31+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
32+
</ul>
33+
</div>

0 commit comments

Comments
 (0)