Skip to content

Commit fc32bce

Browse files
committed
Create: 344-Reverse-String.ts
1 parent aa1fbd6 commit fc32bce

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

typescript/344-Reverse-String.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function reverseString(s: string[]): void {
2+
let l = 0;
3+
let r = s.length - 1;
4+
5+
while (l < r) {
6+
let temp = s[l];
7+
s[l] = s[r];
8+
s[r] = temp;
9+
l += 1;
10+
r -= 1;
11+
}
12+
}

0 commit comments

Comments
 (0)