leetcode解题方案--058--Length of Last Word

来源:互联网 发布:怎么查看mac运行程序 编辑:程序博客网 时间:2024/06/01 10:28

题目

分析

学会了trim方法。
清奇的思路啊

class Solution {    public int lengthOfLastWord(String s) {        s = s.trim();        int lastIndex = s.lastIndexOf(' ') + 1;        return s.length() - lastIndex;            }}
阅读全文
0 0
原创粉丝点击