Appearance
js
/**
* @param {string} s
* @return {number}
*/
var countSegments = function(s) {
return s.split(/\s+/).filter(x => !!x).length
}py
class Solution:
def countSegments(self, s):
"""
:type s: str
:rtype: int
"""
return len(s.split())