Number of Segments in String Problem
Number of Segments in String Problem — ExecCode School DSA Practice
Solve the Number of Segments in String problem on ExecCode. Free online school DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given the input needed to solve Number of Segments in String. Your task is to solve Number of Segments in String. Count the number of segments in a given string. A segment is a contiguous sequence of non-space characters.
Examples
Input Hello, my name is John; Output 5. Input foo bar; Output 2
Constraints
1 <= n <= 10^5
Practice Number of Segments in String free on ExecCode. Browse DSA problems, topic map, and placement guides.