1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/清除数字 [clear-digits].html
2024-06-25 01:21:44 +08:00

48 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串&nbsp;<code>s</code>&nbsp;</p>
<p>你的任务是重复以下操作删除 <strong>所有</strong>&nbsp;数字字符:</p>
<ul>
<li>删除 <strong>第一个数字字符</strong>&nbsp;以及它左边 <strong>最近</strong>&nbsp;<strong>非数字</strong>&nbsp;字符。</li>
</ul>
<p>请你返回删除所有数字字符以后剩下的字符串。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "abc"</span></p>
<p><span class="example-io"><b>输出:</b>"abc"</span></p>
<p><strong>解释:</strong></p>
<p>字符串中没有数字。<!-- notionvc: ff07e34f-b1d6-41fb-9f83-5d0ba3c1ecde --></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "cb34"</span></p>
<p><span class="example-io"><b>输出:</b>""</span></p>
<p><b>解释:</b></p>
<p>一开始,我们对&nbsp;<code>s[2]</code>&nbsp;执行操作,<code>s</code>&nbsp;变为&nbsp;<code>"c4"</code>&nbsp;</p>
<p>然后对&nbsp;<code>s[1]</code>&nbsp;执行操作,<code>s</code>&nbsp;变为&nbsp;<code>""</code>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>s</code>&nbsp;只包含小写英文字母和数字字符。</li>
<li>输入保证所有数字都可以按以上操作被删除。</li>
</ul>