Skip to content

Commit d2f54dd

Browse files
author
shrinathjoshi
committed
refactoring ReverseString.java
1 parent 3e1d2e0 commit d2f54dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

June Challenge/com/leetcode/JuneChallenge/week1/ReverseString.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ public void reverseString(char[] s) {
99
int right = s.length - 1;
1010

1111
while (left < right) {
12-
char temp = s[left];
13-
s[left] = s[right];
14-
s[right] = temp;
12+
s[left] = (char) (s[left] ^ s[right]);
13+
s[right] = (char) (s[right] ^ s[left]);
14+
s[left] = (char) (s[left] ^ s[right]);
1515
left++;
1616
right--;
1717
}

0 commit comments

Comments
 (0)