LeetCode58——Length of Last Word
来源:互联网 发布:js弹出警告窗口 编辑:程序博客网 时间:2024/05/29 09:54
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.
难度系数:
容易
实现
int lengthOfLastWord(const char *s) { int slen = strlen(s); int len = 0; bool bcount = false; while (slen--) { if (s[slen] == ' ') { if (bcount) { break; } else { continue; } } bcount = true; len++; } return len;}
0 0
- LeetCode58——Length of Last Word
- LeetCode58——Length of Last Word
- LeetCode58:Length of Last Word
- Leetcode58 Length of Last Word
- LeetCode58----Length of Last Word
- leetcode58---Length of Last Word
- leetcode58:Length of last word
- Leetcode58: Length of Last Word
- leetcode58: Length of Last Word
- Leetcode58.Length of Last Word
- LeetCode58. Length of Last Word
- LeetCode58 Length of Last Word
- Leetcode58. Length of Last Word
- leetcode58. Length of Last Word
- leetcode58. Length of Last Word
- LeetCode58. Length of Last Word
- Leetcode58-Length of Last Word
- LeetCode——Length of Last Word
- java图形界面五子棋源代码共享
- Android应用程序资源的编译和打包过程分析
- setTimeout传参数
- VC 分割字符串以及去除路径中不合法的字符
- 关于Jenkins的一些新发现
- LeetCode58——Length of Last Word
- Eclipse中git使用初步
- 编写判断一个字符序列是否为回文。回文是指一个字符序列以中间 字符为基准两边字符完全相同,即顺着看和倒着看是相同的字符序列。
- poj2828Buy Tickets
- yii2之layout布局篇
- Android学习:OnLongClickListener长按事件
- ODBC连接数据库总结
- 高斯日记
- 基于UML的软件设计全过程