LeetCode_58. Length of Last Word
58. 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.
Example:
Input: "Hello World"
Output: 5
package leetcode.easy; public class LengthOfLastWord {
@org.junit.Test
public void test() {
System.out.println(lengthOfLastWord("Hello World"));
} public int lengthOfLastWord(String s) {
String str = s.trim();
String[] buff = str.split(" ");
return buff[buff.length - 1].length();
}
}
LeetCode_58. Length of Last Word的更多相关文章
- [LeetCode] Length of Last Word 求末尾单词的长度
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- 【leetcode】Length of Last Word
题目简述 Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return ...
- [LeetCode] Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- [LintCode] Length of Last Word 求末尾单词的长度
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- Java for LeetCode 058 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- LeetCode 58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- 【Length of Last Word】cpp
题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return t ...
- 【LeetCode】58 - Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- Leetcode: Length of Last Word in python
Length of Last Word Total Accepted: 47690 Total Submissions: 168587 Given a string s consists of ...
随机推荐
- 云计算(5)---MapReduce
什么是MapReduce 例如用MapReduce如何计算12+22+32+42 用MapReduce执行Wordcount 步骤1:Map map task1 和map task2是独立,并行进行 ...
- appium+python+iOS 环境搭建,安装fbsimctl
(1)设置postBuffer的值 开始如下的安装之前,需先修改postBuffer的值,默认的比较下,会导致下载大文件时失败, 参考链接:http://blog.sina.com.cn/s/blog ...
- Java Redis+Spring-data-redis 队列 单机版
1.redis.properties ##redisIP地址 #redis.host=10.14.2.212 redis.host=127.0.0.1 ##redis默认端口号 redis.port= ...
- LibreOJ #116. 有源汇有上下界最大流
二次联通门 : LibreOJ #116. 有源汇有上下界最大流 /* LibreOJ #116. 有源汇有上下界最大流 板子题 我也就会写写板子题了.. 写个板子第一个点还死活过不去... 只能打个 ...
- (WAWAWAWAWAWA) BZOJ 1858: [Scoi2010]序列操作
二次联通门 : BZOJ 1858: [Scoi2010]序列操作 /* BZOJ 1858: [Scoi2010]序列操作 已经... 没有什么好怕的的了... 16K的代码... 调个MMP啊.. ...
- (4)打鸡儿教你Vue.js
模板语法: <div id="app"> <p>{{ message }}</p> </div> html 使用 v-html 指令 ...
- 数据结构实验之图论十:判断给定图是否存在合法拓扑序列(SDUT 2140)
分析:BFS判断是否有环. #include<bits/stdc++.h> using namespace std; typedef long long ll; int gra[200][ ...
- hadoop笔记-hdfs文件读写
概念 文件系统 磁盘进行读写的最小单位:数据块,文件系统构建于磁盘之上,文件系统的块大小是磁盘块的整数倍. 文件系统块一般为几千字节,磁盘块一般512字节. hdfs的block.pocket.chu ...
- Mac之Sublime Text使用Go
安装Golang build 包 点击 Preferences > Package control 菜单(MAC快捷键 shift + command + p) 在弹出的输入框输入 instal ...
- IDEA启动Tomcat服务器时某些端口(如1099端口)被占用的解决办法
启动Tomcat服务器时,出现1099端口被其它进程占用了解决办法: 1.找出占用1099端口的进程,进入windows命令,查看什么进程占用了1099端口,使用命令:netstat -aon|fin ...