JAVA -- Easy to read and faster than 100%
class Solution {
    public int lengthOfLastWord(String s) {
        s = s.trim();
        int len = s.length();
        int c = 0;
        for (int x=len-1; x>=0; x--){
            if (s.charAt(x) == ' '){
                break;
            }else{
                c+=1;
            }
        }
        return c;
    }
}
Comments (0)