Skip to content

Instantly share code, notes, and snippets.

@esase
Last active April 1, 2022 08:10
Show Gist options
  • Save esase/471852c23d6679f70b023db79c35da7b to your computer and use it in GitHub Desktop.
Save esase/471852c23d6679f70b023db79c35da7b to your computer and use it in GitHub Desktop.
/**
* @param {character[]} s
* @return {void} Do not return anything, modify s in-place instead.
*/
var reverseString = function(s) {
const inputLength = s.length - 1;
const end = Math.floor(inputLength / 2);
for (let i = 0; i <= end; i++) {
[s[i], s[inputLength - i]] = [s[inputLength - i], s[i]];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment