Skip to content

Commit 3dbd357

Browse files
Adding 344-Reverse-String.js
1 parent aa1fbd6 commit 3dbd357

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

javascript/344-Reverse-String.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {character[]} s
3+
* @return {void} Do not return anything, modify s in-place instead.
4+
*/
5+
var reverseString = function(s) {
6+
let i = 0, j = s.length-1;
7+
8+
while(i <= j) {
9+
let leftval = s[i], rightval = s[j];
10+
s[i] = rightval;
11+
s[j] = leftval;
12+
13+
i++;
14+
j--;
15+
}
16+
};

0 commit comments

Comments
 (0)