Skip to content

Latest commit

 

History

History
17 lines (16 loc) · 339 Bytes

344-reverse-string.md

File metadata and controls

17 lines (16 loc) · 339 Bytes
双指针
/**
 * @param {character[]} s
 * @return {void} Do not return anything, modify s in-place instead.
 */
var reverseString = function(s) {
    let left = 0, right = s.length - 1;
    while(left <= right) {
        [s[left], s[right]] = [s[right], s[left]];
        left++;
        right--;
    }
    return s;
};