Length of Last Word
来源:互联网 发布:cpda数据分析师考试 编辑:程序博客网 时间:2024/05/20 06:55
class Solution {public: int lengthOfLastWord(const char *s) { int len=strlen(s); int start=0; int end=0; bool wordStart=false; bool wordEnd=false; for(int i=len-1;i>=0;--i) { if((wordEnd)&&(s[i]==' ')) { wordStart=true; start=i+1; break; } if(s[i]==' ') { continue; } if(!wordEnd) { end=i+1; wordEnd=true; } } return end-start; }};
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
- 数据结构和算法基本概念
- Java Enum 学习
- Linux最帅版主所经历的面试题,全部答对月薪10K+ ...
- 关于Tp中图片路径的问题
- 让vim显示空格,及tab字符 vim 多行注释
- Length of Last Word
- 关于iOS8下注册本地通知的一些笔记
- Maven仓库管理-Nexus
- Linux最帅版主所经历的面试题,全部答对月薪10K+ ...答案公布
- 芯客-互联网硬件化的最强支柱
- 在linux下出现cannot restore segment prot after reloc: Permission denied
- android nfc中MifareClassic格式的读写
- 结构型模式-外观
- nyoj题目67:三角形面积