[LeetCode]58. Length of Last Word
来源:互联网 发布:用js怎么写九九乘法表 编辑:程序博客网 时间:2024/06/02 02:28
题目描述: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.
分析:返回一个长传字符串中最后一个单词的长度,单词之间以空格分割
解题思路:将字符串利用正则表达式切割,然后返回字符串中最后一个单词的长度。
public int lengthOfLastWord(String s) { if(s==null||s.length()==0)return 0; s = s.trim(); String[] split = s.split("\\s"); return split[split.length-1].length(); }
阅读全文
0 0
- 58. Length of Last Word Leetcode Python
- [LeetCode]58.Length of Last Word
- LeetCode --- 58. Length of Last Word
- [Leetcode] 58. Length of Last Word
- [leetcode] 58.Length of Last Word
- LeetCode - 58. Length of Last Word
- <LeetCode OJ> 58. Length of Last Word
- 58. Length of Last Word LeetCode
- 【LeetCode】58. Length of Last Word
- leetcode 58. Length of Last Word
- LeetCode *** 58. Length of Last Word
- LeetCode 58. Length of Last Word
- leetcode-58. Length of Last Word
- LeetCode-58.Length of Last Word
- [leetcode] 58. Length of Last Word
- LeetCode 58. Length of Last Word
- Leetcode-58. Length of Last Word
- leetcode-java-58. Length of Last Word
- json数据解析
- 深度学习系列之(dlib+opencv)代码收藏
- 10月20日云栖精选夜读:揭秘云栖大会VR直播云服务解决方案的技术亮点和核心能力
- 菜单权限设计实现
- Linux的琐碎事儿~~
- [LeetCode]58. Length of Last Word
- erlang开发工具之intellij idea基本使用
- Java中文转GBK码
- <背包DP>codevs 1684 垃圾陷阱
- Yaml简易学习
- Animation Silder实现动画播时滑动条随之滑动
- android面试-内存泄漏(美图、久邦面涉及到)
- JDK7中ExecutorService源码概述
- 揭秘云栖大会VR直播云服务解决方案的技术亮点和核心能力