Length of Last Word

来源:互联网 发布:基因监测与大数据分析 编辑:程序博客网 时间:2024/06/06 15:37
public class Solution {    public int lengthOfLastWord(String s) {        int length = 0;        for (int i=s.length()-1; i>=0; i--){            if (s.charAt(i) != ' '){                length++;            }else{                if (length>0){                    return length;                }            }        }        return length;    }}

0 0
原创粉丝点击