js two line(whick first line include check s if null)


  • 0
    X
    var countSegments = function(s) {
        if(!s) return 0;
        return s.split(' ').filter(val => {return val !== ''}).length;
    };
    

Log in to reply
 

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