Short and easy to understand solution JAVA


  • 0
    P
    public int lengthOfLastWord(String s) {
        s = s.trim();
        String[] strArr = s.split(" ");
        return strArr[strArr.length-1].length();
    }

Log in to reply
 

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