Length of last word
2013-05-13 03:52
162 查看
class Solution { public: int lengthOfLastWord(const char *s) { // Start typing your C/C++ solution below // DO NOT write int main() function if (*s == NULL) return 0; int length = 0; int result = 0; while (*s){ if (*s == ' ') { length = 0; s++; } else { length++; result = length; s++; } } return result; } };
相关文章推荐
- Java [Leetcode 58]Length of Last Word
- [LintCode]Length of Last Word
- LeetCode OJ:Length of Last Word
- String-58-Length of Last Word
- [leetcode][JavaScript]Length of Last Word
- LeetCode-Length of Last Word
- [C++]LeetCode: 23 Length of Last Word
- leetcode 058 —— Length of Last Word
- Length of Last Word leetocde java
- lengthOfLastWord
- leetcode 58 Length of Last Word
- 058 - Length of Last Word
- [LeetCode] Length of Last Word
- Length of Last Word
- LeetCode(48)-Length of Last Word
- Length of Last Word
- LeetCode之路—— LeetCode58 Length of Last Word
- Length of Last Word
- Leetcode 细节实现 Length of Last Word
- leetcode -- Length of Last Word