super simple probably not super efficient


  • 0
    M
    here we go.
    
    public int lengthOfLastWord(String s) {
            String[] strs = s.split(" ");
            return strs.length == 0 ? 0 : strs[strs.length-1].length();
        }

Log in to reply
 

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