Tap here to switch tabs
Problem
Submissions

Problem: Number of Segments in a String

med
30 min
Try to solve the Number of Segments in a String problem.

Statement

Given a string s, return the total number of segments present in the string.

A segment is defined as a contiguous sequence of characters that are not spaces.

Constraints:

  • 0≤0 \leq s.length ≤300\leq 300

  • s consists of lowercase and uppercase English letters, digits, or one of the following characters: "!@#$%^&*()_+-=',.:".

  • The only space character in s is ' '.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Segments in a String

med
30 min
Try to solve the Number of Segments in a String problem.

Statement

Given a string s, return the total number of segments present in the string.

A segment is defined as a contiguous sequence of characters that are not spaces.

Constraints:

  • 0≤0 \leq s.length ≤300\leq 300

  • s consists of lowercase and uppercase English letters, digits, or one of the following characters: "!@#$%^&*()_+-=',.:".

  • The only space character in s is ' '.