1-Line JavaScript Code


  • 0
    Z

    /**

    • @param {string} s
    • @return {number}
      */
      var countSegments = function(s) {
      return (s.replace(/\s+/g, ' ').trim() === '' ? 0 : s.replace(/\s+/g, ' ').trim().split(' ').length);
      };

Log in to reply
 

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