-
Notifications
You must be signed in to change notification settings - Fork 160
/
reverse-only-letters.md
51 lines (40 loc) · 1.25 KB
/
reverse-only-letters.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<p>Given a string <code>S</code>, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.</p>
<p> </p>
<div>
<div>
<div>
<ol>
</ol>
</div>
</div>
</div>
<div>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-1-1">"ab-cd"</span>
<strong>Output: </strong><span id="example-output-1">"dc-ba"</span>
</pre>
<div>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-2-1">"a-bC-dEf-ghIj"</span>
<strong>Output: </strong><span id="example-output-2">"j-Ih-gfE-dCba"</span>
</pre>
<div>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-3-1">"Test1ng-Leet=code-Q!"</span>
<strong>Output: </strong><span id="example-output-3">"Qedo1ct-eeLg=ntse-T!"</span>
</pre>
<p> </p>
<div>
<p><strong><span>Note:</span></strong></p>
<ol>
<li><code>S.length <= 100</code></li>
<li><code>33 <= S[i].ASCIIcode <= 122</code> </li>
<li><code>S</code> doesn't contain <code>\</code> or <code>"</code></li>
</ol>
</div>
</div>
</div>
</div>