Advertisement
tanchukw

Untitled

Jul 29th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1.  
  2. class Solution
  3. {
  4. public:
  5.     int lengthOfLastWord(string s)
  6.     {
  7.         int size = s.size() - 1, len = 0;
  8.         while (size >= 0 && !((s[size] >= 'a' && s[size] <= 'z') || (s[size] >= 'A' && s[size] <= 'Z')))
  9.             size--;
  10.         while (size >= 0 && ((s[size] >= 'a' && s[size] <= 'z') || (s[size] >= 'A' && s[size] <= 'Z')))
  11.         {
  12.             size--;
  13.             len++;
  14.         }
  15.         return len;
  16.     }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement