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)/删除字符串中的所有相邻重复项 [remove-all-adjacent-duplicates-in-string].html
2022-03-29 12:43:11 +08:00

25 lines
1016 B
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><strong>重复项删除操作</strong>会选择两个相邻且相同的字母,并删除它们。</p>
<p>在 S 上反复执行重复项删除操作,直到无法继续删除。</p>
<p>在完成所有重复项删除操作后返回最终的字符串。答案保证唯一。</p>
<p>&nbsp;</p>
<p><strong>示例:</strong></p>
<pre><strong>输入:</strong>&quot;abbaca&quot;
<strong>输出:</strong>&quot;ca&quot;
<strong>解释:</strong>
例如,在 &quot;abbaca&quot; 中,我们可以删除 &quot;bb&quot; 由于两字母相邻且相同,这是此时唯一可以执行删除操作的重复项。之后我们得到字符串 &quot;aaca&quot;,其中又只有 &quot;aa&quot; 可以执行重复项删除操作,所以最后的字符串为 &quot;ca&quot;
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ol>
<li><code>1 &lt;= S.length &lt;= 20000</code></li>
<li><code>S</code> 仅由小写英文字母组成。</li>
</ol>