2-line JavaScript solution


  • 0
    P
    var lengthOfLastWord = function(s) {
        let array = s.trim().split(' ');
        return array[array.length -1].length;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.