[Algorithm] 1 week(1.10 ~ 16) 2/3

2687 단어 algorithmalgorithm

LeetCode 557. Reverse Words in a String III

var reverseWords = function(s) {
    const splitStr = s.split(' ');
    const result = [];
    
    for(let i = 0; i < splitStr.length; i++){
        result.push(splitStr[i].split('').reverse().join(''))
    }
    
    return result.join(' ')
};

좋은 웹페이지 즐겨찾기