2 lines 0MS java solution


  • 1
    Q
    public int lengthOfLastWord(String s) {
        s= s.trim();
        return s.length() - 1 - s.lastIndexOf(" ");
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.