Skip to content

Commit 1461e42

Browse files
authored
Create 344-reverse-string.js
1 parent 2185634 commit 1461e42

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

344-reverse-string.js

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

0 commit comments

Comments
 (0)