Length of Last Word
2013-07-24 18:54
176 查看
class Solution { public: int lengthOfLastWord(const char *s) { // Start typing your C/C++ solution below // DO NOT write int main() function int len=strlen(s),p=len-1,cnt=0; while(p>=0&&s[p]==' '){ --p; } while(p>=0&&s[p]!=' '){ --p; ++cnt; } return cnt; } };
相关文章推荐
- leetcode解题之58 # Length of Last Word Java版
- Length of Last Word
- [LeetCode 58]Length of Last Word
- LeetCode-Length of Last Word
- LeetCode | Length of Last Word
- leetcode_58 Length of Last Word C++
- LeetCode: Length of Last Word
- 30_leetcode_Length of Last Word
- [leetcode 58]Length of Last Word
- Length of Last Word
- LeetCode 57 Length of Last Word
- leetcode笔记--Length of Last Word
- Length of Last Word
- LeetCode——Length of Last Word
- LeetCode 58 - Length of Last Word
- [LeetCode] Length of Last Word
- Length of Last Word
- LeetCode: Length of Last Word
- [LeetCode]Length of Last Word
- Length of Last Word leetocde java