public int lengthOfLastWord(String s) {
        // Write your code here
        s = s.trim();
        int count = 0;
        for (int i = s.length() - 1; i >= 0; --i) {
            if (s.charAt(i) == ' ')
                break;
            count++;
        }
        return count;
    }