Given a string S consisting of upper/lower-case alphabets and empty space characters ‘ ‘. The string may contain spaces at the end. You will have return the length of last word which consists of alphabets only.
S = "Geeks for Geeks"
Explanation: The last word is "Geeks"
of length 5.
S = "Start Coding Here "
Explanation: The last word is "Here" of
You don't need to read input or print anything.Your task is to complete the function findLength() which takes a single argument(string S) and returns the length of last word of the string.
Expected Time Complexity: O(|S|). Expected Auxiliary Space: O(1).