Length Last Wrod | Strings | C++ Solution
Length Last Wrod, is a Strings related problem and in this post we will see how we can solve this challenge in C++
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.
Note: A word is defined as a character sequence consists of non-space characters only.
Given s = "Hello World",
return 5 as length("World") = 5. Traverse from the end and go till the first non-space character since there can be space after the last word also then starrt counting till the first space ignore all spaces from end
Please check the main.cpp snippet for the solution.
This solution originally posted at: Github by @susantabiswas