-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<h2><a href="https://leetcode.com/problems/remove-k-digits/">402. Remove K Digits</a></h2><h3>Medium</h3><hr><div><p>Given string num representing a non-negative integer <code>num</code>, and an integer <code>k</code>, return <em>the smallest possible integer after removing</em> <code>k</code> <em>digits from</em> <code>num</code>.</p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<pre><strong>Input:</strong> num = "1432219", k = 3 | ||
<strong>Output:</strong> "1219" | ||
<strong>Explanation:</strong> Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest. | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<pre><strong>Input:</strong> num = "10200", k = 1 | ||
<strong>Output:</strong> "200" | ||
<strong>Explanation:</strong> Remove the leading 1 and the number is 200. Note that the output must not contain leading zeroes. | ||
</pre> | ||
|
||
<p><strong>Example 3:</strong></p> | ||
|
||
<pre><strong>Input:</strong> num = "10", k = 2 | ||
<strong>Output:</strong> "0" | ||
<strong>Explanation:</strong> Remove all the digits from the number and it is left with nothing which is 0. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= k <= num.length <= 10<sup>5</sup></code></li> | ||
<li><code>num</code> consists of only digits.</li> | ||
<li><code>num</code> does not have any leading zeros except for the zero itself.</li> | ||
</ul> | ||
</div> |