Guest User

Untitled

a guest
Feb 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int lengthOfLastWord(string s) {
  4. int len = 0, tail = s.length() - 1;
  5. while (tail >= 0 && s[tail] == ' ') tail--;
  6. while (tail >= 0 && s[tail] != ' ') {
  7. len++;
  8. tail--;
  9. }
  10. return len;
  11. }
  12. };
Add Comment
Please, Sign In to add comment