Length of Last Word
来源:互联网 发布:java哪吒封神榜 编辑:程序博客网 时间:2024/05/17 17:57
设置一个变量显示是否读了新单词
若新单词,标识一下。
public class Solution {public int lengthOfLastWord(String s) {// Start typing your Java solution below// DO NOT write main() functionint len = s.length();if (len == 0)return 0;int i = 0;int count = 0;boolean is_new = true;while (i < len) {if (s.charAt(i) == ' ') {is_new = true;} else {if (is_new == true) {count = 1;is_new = false;} elsecount++;}i++;}return count;}}
- 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
- android 手势识别
- 数据库导入Excel数据的简易方法
- Android中使用SDcard进行文件的读取方法
- fedora17的U盘安装和硬盘安装
- ADF11g-032: SelectManyShuttle组件的简单使用
- Length of Last Word
- Squid配置反向代理
- Java clone()
- 在Fedora 下建立 ARM-Linux 交叉编译环境
- 【风宇冲】Unity3D教程宝典之 C#代码注释规范及文档生成
- ALSA声音编程介绍(译文)
- CentOS 6.4 Openstack Grizzly 安装配置 (Open VSwitch 单节点)
- Java 文件分块上传客户端源代码 Java 文件分块上传服务器端源代码
- 简单的存储过程例子