Skip to content

Commit a5b1678

Browse files
refactor 917
1 parent ff5c33d commit a5b1678

File tree

1 file changed

+1
-27
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-27
lines changed

src/main/java/com/fishercoder/solutions/_917.java

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 917. Reverse Only Letters
5-
*
6-
* Given a string S, return the "reversed" string where all characters
7-
* that are not a letter stay in the same place, and all letters reverse their positions.
8-
*
9-
* Example 1:
10-
*
11-
* Input: "ab-cd"
12-
* Output: "dc-ba"
13-
* Example 2:
14-
*
15-
* Input: "a-bC-dEf-ghIj"
16-
* Output: "j-Ih-gfE-dCba"
17-
* Example 3:
18-
*
19-
* Input: "Test1ng-Leet=code-Q!"
20-
* Output: "Qedo1ct-eeLg=ntse-T!"
21-
*
22-
*
23-
* Note:
24-
*
25-
* S.length <= 100
26-
* 33 <= S[i].ASCIIcode <= 122
27-
* S doesn't contain \ or "
28-
* */
293
public class _917 {
304
public static class Solution1 {
315
public String reverseOnlyLetters(String S) {
326
char[] array = S.toCharArray();
33-
for (int i = 0, j = array.length - 1; i < j;) {
7+
for (int i = 0, j = array.length - 1; i < j; ) {
348
if (Character.isLetter(array[i]) && Character.isLetter(array[j])) {
359
char temp = array[i];
3610
array[i++] = array[j];

0 commit comments

Comments
 (0)