博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Length of Last Word
阅读量:4074 次
发布时间:2019-05-25

本文共 531 字,大约阅读时间需要 1 分钟。

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.

For example,

Given s = "Hello World",
return 5.

Java代码;

public class Solution {    public int lengthOfLastWord(String s) {        if(s.trim().equals(""))			return 0;				String[] array = s.split(" ");				return array[array.length-1].length();    }}

转载地址:http://ejuni.baihongyu.com/

你可能感兴趣的文章
λ怎么 读
查看>>
Rect 和 Bounds
查看>>
HOLOLENS不适合加天空盒
查看>>
Unity UI on hololens
查看>>
Unity 下载存档
查看>>
3D游戏常用技巧Normal Mapping (法线贴图)原理解析——基础篇
查看>>
学UNITY的基础
查看>>
What is a RaycastHit normal?
查看>>
Vector3.forward
查看>>
Unity新功能|全息模拟器
查看>>
[Unity3D]深度相机 Depth Camera
查看>>
发布和运行HOLOLENS程序注意这里要勾上,不然就成普通的UWP程序了!
查看>>
Hololens入门之语音识别(语音命令)
查看>>
[自学总结] Unity5.3 API 之 Audio Mixer
查看>>
UNITY 之FixedUpdate
查看>>
HOLOLENS程序发布,这个界面调用的图片
查看>>
看出在玩啥了吗?想不想体验下
查看>>
Time.deltaTime 的平均值在0.1-0.2左右
查看>>
向量加减法运算及其几何意义
查看>>
magnitude是精确距离,sqrMagnitude是节省CPU的粗略距离,精度有损失
查看>>