Given a string s, return the number of words in the string.
A word is defined as a contiguous sequence of non-space characters. The string may contain leading spaces, trailing spaces, and multiple spaces between words.
s = "Hello World"2s = " fly me to the moon "5s = "onlyoneword"10 <= s.length <= 10^5s consists of English letters and spaces.Run your code to see results
Use Cmd+Enter to run