字符串 Length of Last Word
2015-04-09 21:03
190 查看
思想:
只有字母、空格、'\0'三种类型的字符。
只有字母、空格、'\0'三种类型的字符。
class Solution { public: int lengthOfLastWord(const char *s) { if(s == NULL) return 0; int length = 0; while(*s) { if(*s++!=' ') { length++; }else if(*s && *s!=' ') { length = 0; } } return length; } };
相关文章推荐
- leetcode:字符串之Length of Last Word
- leetcode---length-of-last-word---字符串
- LeetCode练习-字符串-length-of-last-word
- LeetCode_Length of Last Word
- LeetCode-Length of Last Word
- [LeetCode] Length of Last Word
- Length of Last Word
- [Leetcode 3] 58 Length of Last Word
- Length of Last Word
- Length of Last Word
- leetcode 21: Length of Last Word
- leetcode 21: Length of Last Word
- leetcode: Length of Last Word
- [leetcode]Length of Last Word
- JS:1.8,字符串(string)对象(length,indexOf(),lastIndexOf(),replace(),match(),toUpperCase(),toLowerCase())
- [LeetCode] Length of Last Word
- Length of Last Word
- 【LeetCode with Python】 Length of Last Word
- LeetCode Online Judge 题目C# 练习 - Length of Last Word
- LeetCode: Length of Last Word