leetcode[58]:Length of Last Word
来源:互联网 发布:淘宝大尺度 编辑:程序博客网 时间:2024/04/26 15:37
Length of Last Word
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(char* s) { int i; int len=strlen(s); while(s[len-1] == ' ') len--; for(i=len; i>0; i--) { if(s[i-1] == ' ') return len-i; } return len;}
简单题目,注意句子末尾的空格去除即可。
0 0
- [leetcode 58] Length of Last Word
- leetcode-58 Length of Last Word
- Leetcode NO.58 Length of Last Word
- LeetCode #58 length of Last Word
- [LeetCode 58]Length of Last Word
- leetcode || 58、Length of Last Word
- LeetCode 58 Length of Last Word
- [Leetcode 58, easy] Length of Last Word
- Length of Last Word (leetCode 58)
- leetcode[58]:Length of Last Word
- 【leetcode c++】58 Length of Last Word
- leetcode 58:Length of Last Word
- LeetCode---(58)Length of Last Word
- leetcode-58-Length of Last Word
- Leetcode# 58 Length of Last Word
- [leetcode-58]Length of Last Word(c)
- leetcode 58: Length of Last Word
- leetCode #58 Length of Last Word
- Mysql 事务
- mysqldump Got error: 1449
- Sort List -- leetcode
- hunnu11550:欧拉函数
- Hadoop对小文件的解决方案
- leetcode[58]:Length of Last Word
- android学习笔记(一)activity的基本用法和创建,bundle如何传递数据,intent的用法
- Cordic算法的FPGA实现之原理学习随记
- 第十四周项目一--小玩文件
- CORDIC算法的FPGA实现
- java中的IO流(1)----读取二进制文件
- namespace命名空间
- javaSWing程序命令行和IDE运行没有问题,打包成jar后直接双击运行部分功能不行
- 数据通信问题解决之后的工作