luoheng
10/14/2019 - 7:37 AM

countSegments

func countSegments(s string) int {
    f, sum := true, 0
    for i := 0; i < len(s); i++ {
        if s[i] != ' ' {
            if f {
                sum++
                f = false
            }
        } else {
            f = true
        }
    }
    return sum
}