Count Words in a String — C# Coding Problem
Difficulty: easy | Category: string
Problem Description
Given a string `s`, return the number of words in it. Words are separated by one or more spaces. Leading and trailing spaces should be ignored. Return `0` for an empty string or a string containing only spaces.
Examples
Example 1
Input: s = "hello world"
Output: 2
Example 2
Input: s = " the quick brown fox "
Output: 4
Example 3
Input: s = ""
Output: 0