You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/0900-0999/0917.Reverse Only Letters/README_EN.md
+40-32
Original file line number
Diff line number
Diff line change
@@ -37,47 +37,51 @@
37
37
38
38
## Solutions
39
39
40
-
### Solution 1
40
+
### Solution 1: Two Pointers
41
+
42
+
We use two pointers $i$ and $j$ to point to the head and tail of the string respectively. When $i < j$, we continuously move $i$ and $j$ until $i$ points to an English letter and $j$ points to an English letter, then we swap $s[i]$ and $s[j]$. Finally, we return the string.
43
+
44
+
The time complexity is $O(n)$, and the space complexity is $O(n)$, where $n$ is the length of the string.
0 commit comments