Given a string input_str consisting of English letters and spaces, return the length of the last contiguous sequence of non-space characters (word) in input_str. A word is defined as a maximal substring of consecutive non-space characters.
Example 1
Input: data science is fun
Output: 3
Explanation: The last word is fun, which has length 3.
Example 2
Input: python programming
Output: 11
Explanation: The last word is programming, which has length 11.
Example 3
Input: algorithm
Output: 9
Explanation: The last word is algorithm, which has length 9.
Constraints
Case 1
Input: 'machine learning rocks'
Expected: 5
Case 2
Input: ' hello world '
Expected: 5
Case 3
Input: 'openai'
Expected: 6
Case 4
Input: 'deep neural networks '
Expected: 8
Case 5
Input: ' a b c d e f g '
Expected: 1