Length of Last Word
来源:互联网 发布:马伊琍 哪里漂亮 知乎 编辑:程序博客网 时间:2024/05/19 09:49
class Solution {public: int lengthOfLastWord(string s) { if(s.empty()) return 0; int count=0; bool firstspace=true; const int n=s.size(); for(int i=n-1;i>=0;--i) { if(s[i]!=' ') { ++count; firstspace=false; } if(s[i]==' '&& firstspace) continue; if(s[i]==' '&& !firstspace) return count; } return count; }};
0 0
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- Length of Last Word
- sql学习笔记(10)-----------sql函数(5)
- 5 个问题
- 44、对象的深克隆与浅克隆
- Mysql配置文件my.cnf配置及配置参数详解
- 程序员应该具备的十个代码习惯
- Length of Last Word
- 45、java网络编程
- 二叉树的镜像
- 46、JVM之类加载器
- 基于GDAL的栅格图像读写与转换——C#语言版
- 写在hibernate里面的sql setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
- 推荐的Oracle书籍
- css学习
- Java关闭钩子的应用