mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
update
This commit is contained in:
45
leetcode/problem/clear-digits.html
Normal file
45
leetcode/problem/clear-digits.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<p>You are given a string <code>s</code>.</p>
|
||||
|
||||
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
|
||||
|
||||
<ul>
|
||||
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return the resulting string after removing all digits.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>Input:</strong> <span class="example-io">s = "abc"</span></p>
|
||||
|
||||
<p><strong>Output:</strong> <span class="example-io">"abc"</span></p>
|
||||
|
||||
<p><strong>Explanation:</strong></p>
|
||||
|
||||
<p>There is no digit in the string.<!-- notionvc: ff07e34f-b1d6-41fb-9f83-5d0ba3c1ecde --></p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>Input:</strong> <span class="example-io">s = "cb34"</span></p>
|
||||
|
||||
<p><strong>Output:</strong> <span class="example-io">""</span></p>
|
||||
|
||||
<p><strong>Explanation:</strong></p>
|
||||
|
||||
<p>First, we apply the operation on <code>s[2]</code>, and <code>s</code> becomes <code>"c4"</code>.</p>
|
||||
|
||||
<p>Then we apply the operation on <code>s[1]</code>, and <code>s</code> becomes <code>""</code>.</p>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 100</code></li>
|
||||
<li><code>s</code> consists only of lowercase English letters and digits.</li>
|
||||
<li>The input is generated such that it is possible to delete all digits.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user