赞
踩
- class Solution {
- public int lengthOfLastWord(String s) {
- int i = s.length()-1;
- int count = 0;
- while (i>=0&&s.charAt(i)==' ') {
- i--;
- }
- while (i>=0&&s.charAt(i)!=' ') {
- count++;
- i--;
- }
- return count;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。