Given a string s consists of upper/lower-case alphabets and empty space characters
' ', return the length of last word in the string.
If the last word does not exist, return 0.
A word is defined as a character sequence consists of non-space characters only.
s = "Hello World", return
This is a simple string processing problem with many ways of solving it. Here we present a simple algorithm.
The idea is to find the start and end index of the last word. Remember the string could have trailing spaces, so the last word doe not necessary ends at the last index of the string.
The Java implementation of the algorithm follows.