@@ -0,0 +1,951 @@
+/*%0AGiven a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.%0A%0AIf the last word does not exist, return 0.%0A%0ANote: A word is defined as a character sequence consists of non-space characters only.%0A%0AFor example,%0AGiven s = %22Hello World%22,%0Areturn 5. %0A*/%0A%0Aimport java.util.*;%0A%0Apublic class LengthofLastWord %7B%0A%09public static int lengthOfLastWord(String s) %7B%0A        if(s.length() == 0) return 0;%0A        if(s.length() == 1) return s.charAt(0) != ' ' ? 1:0;%0A        int L = s.length();%0A        int i = L-1;%0A        int a = L-1;%0A        while( i %3E= 0 && s.charAt(i) == ' ') i--;%0A        a = i;%0A        while(i%3E=0 && s.charAt(i) != ' ') i--;%0A        return a-i;%0A    %7D%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String s = %22 hello world     %22;%0A%09%09System.out.println(%22string: %22 + s);%0A%09%09int res = lengthOfLastWord(s);%0A%09%09System.out.println(%22the last word's length: %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

length of last word