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; } }