Simple Java Solution


  • 0
    E

    class Solution {
    public int lengthOfLastWord(String s) {
    String[] strs = s.trim().split("\s+");
    return 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.