Skip to content

Commit

Permalink
Adding 344-Reverse-String.js
Browse files Browse the repository at this point in the history
  • Loading branch information
FahadulShadhin committed Oct 31, 2022
1 parent aa1fbd6 commit 3dbd357
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions javascript/344-Reverse-String.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @param {character[]} s
* @return {void} Do not return anything, modify s in-place instead.
*/
var reverseString = function(s) {
let i = 0, j = s.length-1;

while(i <= j) {
let leftval = s[i], rightval = s[j];
s[i] = rightval;
s[j] = leftval;

i++;
j--;
}
};

0 comments on commit 3dbd357

Please sign in to comment.