Solved LeetCode program · 317 of 1,000
#0434 · Number of Segments in a String
Original English source
The sentence is "Hello, my name is John". The last is the last position of sentence. The count is 0. The inside is 0.
For every spot from 0 to last.
The symbol is character spot of sentence. If symbol is " ", set inside to 0. If symbol is not " " and inside is 0, add 1 to count, set inside to 1.
Show count.
Expected stdout
5