Length of Last Word
来源:互联网 发布:怎样举报淘宝店铺 编辑:程序博客网 时间:2024/06/07 01:09
public class Solution { public int lengthOfLastWord(String s) { int res = 0; if(s.length() == 0){ return res; } char[] sArray = s.toCharArray(); boolean startWithSpace = false; if(sArray[sArray.length - 1] == ' '){ startWithSpace = true; } for(int i = sArray.length - 1; i >= 0 ; i--){ if(!startWithSpace){ if(sArray[i] != ' '){ res++; }else{ break; } }else{ if(sArray[i] == ' '){ continue; }else{ res++; startWithSpace = false; } } } return res; }}
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
- 用lead分析函数构造类似9*9乘法口诀的功能
- JavaScript:让构造器函数 不管用不用new 都可以生成 正确的对象。
- MTK gpio
- linux dup,dup2,dup3 复制一个文件描述符
- iOS Core Data的使用
- Length of Last Word
- JAVA JNA 调用 .so
- iOS中的KVC
- 第十一周 项目2--职员有薪水了(用深复制)
- iOS下KVO的使用以及一些实现细节
- 使用Eclipse构建Maven项目 (step-by-step)
- 【STL专项练习】热血格斗场
- Device Context 设备环境 设备上下文 理解
- 2700年前齐桓公玩弄的货币战争,今天的中国也在上演?!