leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0058.cpp (246B)
0 class Solution {
1 public:
2 int lengthOfLastWord(string s) {
3 int i = s.size(), res = 0;
4 while (--i >= 0 && isspace(s[i]))
5 ;
6 while (i >= 0 && !isspace(s[i--]))
7 res++;
8 return res;
9 }
10 };