public int lengthOfLastWord(String s) {
        if(s == null || s.length() == 0) return 0;
        s = s.trim();
        
        int ans = 0;
        for(int i = s.length()-1; i >= 0; i--){
            if(s.charAt(i) != ' ') ans++;
            else return ans;
        }
        return ans;
    }