58. Length of Last Word
来源:互联网 发布:手机淘宝的id号在哪里 编辑:程序博客网 时间:2024/04/29 03:47
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 class Solution { public int lengthOfLastWord(String s) { String [] sp = s.split(" "); //for(int i=sp.length;i>=0;i--){ for(int i=sp.length-1;i>=0;i--){ if(sp[i].length()>0) return sp[i].length(); } return 0; }}
0 0
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58. Length of Last Word
- 58.Length of Last Word
- matlab——eemd函数的使用
- 后台json数据为空,解析 出现空指针异常
- LeeCode(Database)-Combine Two Tables
- 自定义控件三部曲之绘图篇(九)——Paint之setColorFilter
- 用小猫统计制作运动员评价管理系统:先制作各个数据库表的excel模板
- 58. Length of Last Word
- YOLO image结构体操作学习
- 从原理看Kruskal与Prim求最小生成树
- LeeCode(Database)-Employees Earning More Than Their Managers
- js里面的Timer
- 27. Remove Element
- c++ 11(四)
- mac环境使用sed修改文件出错的解决方法
- HDU5610 Baby Ming and Weight lifting 大水题