Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 632cce7

Browse files
committed
917 added
1 parent f66b74e commit 632cce7

File tree

4 files changed

+47
-50
lines changed

4 files changed

+47
-50
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"todo-tree.flat": true,
33
"cSpell.words": [
4+
"ASCI",
5+
"Icode",
46
"Puerkito",
7+
"Qedo",
58
"Subarrays",
69
"boustrophedonically",
710
"chromedp",
@@ -14,6 +17,7 @@
1417
"leetcode",
1518
"mozillazg",
1619
"nbsp",
20+
"ntse",
1721
"pwwkew",
1822
"rorse",
1923
"stretchr",
Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,30 @@
11
# [917. Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/)
22

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

Algorithms/0917.reverse-only-letters/reverse-only-letters_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@ import (
99

1010
// tcs is testcase slice
1111
var tcs = []struct {
12-
S string
12+
S string
1313
ans string
1414
}{
1515

16+
{
17+
"ab-cd",
18+
"dc-ba",
19+
},
1620

21+
{
22+
"a-bC-dEf-ghIj",
23+
"j-Ih-gfE-dCba",
24+
},
25+
26+
{
27+
"Test1ng-Leet=code-Q!",
28+
"Qedo1ct-eeLg=ntse-T!",
29+
},
1730

1831
// 可以有多个 testcase
1932
}

leetcode.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Username": "aQuaYi",
33
"Ranking": 882,
4-
"Updated": "2018-12-01T16:08:46.429674502+08:00",
4+
"Updated": "2018-12-01T16:13:03.850957414+08:00",
55
"Record": {
66
"Easy": {
77
"Solved": 203,

0 commit comments

Comments
 (0)