leetcode: Length of Last Word
来源:互联网 发布:软件功能ppt介绍 编辑:程序博客网 时间:2024/06/05 20:29
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 ret = 0; char *pCur = (char *)s; char *pBase; while (*pCur != '\0') { pCur++; } pCur--; while (pCur >= s) { while (pCur >= s && *pCur == ' ') pCur--; if (pCur < s) break; pBase = pCur; while (pCur >=s && *pCur != ' ') pCur--; return pBase-pCur; } return 0; }};
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
- Ubuntu系统下嵌入式inux动态库的开发
- linux 下c++线程池的简单实现(在老外代码上添加注释)
- C++对象指针
- 手写yueshu
- 单片机中推挽输出是什么意思
- leetcode: Length of Last Word
- struts2,hibernate4,spring3配置时问题汇总及解决办法(架包导入问题)
- Android查询:模拟键盘鼠标事件(adb shell 实现)
- html A标签的onclick事件和href的使用
- linux(ubuntu)常用命令(1)
- C#对象XML序列化:序列化方法和常用特性
- 创建DB2数据库
- 队列(2)----用数组实现队列
- 访问web-inf下面的jsp文件