[LeetCode] Length of Last Word
来源:互联网 发布:linux守护线程 编辑:程序博客网 时间:2024/06/06 15:51
Given a string s consists of upper/lower-case alphabets and empty space characters' '
, return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
For example,
Given s = "Hello World"
,
return 5
.
class Solution {public: int lengthOfLastWord(const char *s) { int count = 0,last = 0; while(*s != '\0'){ count = *s == ' ' ? 0 : count + 1; last = count > 0 ? count : last; s ++; } return last; }};
0 0
- 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
- [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
- 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
- Object-c 总结之NSDate
- IOS CALayer详解
- 作业
- Git分支开发图解
- eclipse最有用快捷键整理
- [LeetCode] Length of Last Word
- BZOJ 1030 JSOI 2007 文本生成器 AC自动机+DP
- 大规模分布式存储系统-读书笔记-第一章
- android Scoket 网络对战DEMO
- Nginx配置文件详细说明
- 为什么opencv用GPU实现比用CPU实现的慢?
- restclient 客户端
- 可在每个Activity捕获异常(或者在app中全程捕获)
- activity与service通过serializable传递复杂对象