1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/仅仅反转字母 [reverse-only-letters].html
2022-03-29 12:43:11 +08:00

51 lines
1009 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>给你一个字符串 <code>s</code> ,根据下述规则反转字符串:</p>
<ul>
<li>所有非英文字母保留在原有位置。</li>
<li>所有英文字母(小写或大写)位置反转。</li>
</ul>
<p>返回反转后的 <code>s</code><em></em></p>
<p>&nbsp;</p>
<ol>
</ol>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "ab-cd"
<strong>输出:</strong>"dc-ba"
</pre>
<ol>
</ol>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "a-bC-dEf-ghIj"
<strong>输出:</strong>"j-Ih-gfE-dCba"
</pre>
<ol>
</ol>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = "Test1ng-Leet=code-Q!"
<strong>输出:</strong>"Qedo1ct-eeLg=ntse-T!"
</pre>
<p>&nbsp;</p>
<p><strong>提示</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>s</code> 仅由 ASCII 值在范围 <code>[33, 122]</code> 的字符组成</li>
<li><code>s</code> 不含 <code>'\"'</code><code>'\\'</code></li>
</ul>