Simple and easy in java


#1

public int lengthOfLastWord(final String A) {

    String[] str=A.split("\\s");
    for(int i=str.length-1;i>=0;i--)
    {
        if(!str[i].equals("\\s"))
        {
            return str[i].length();
        }
    }
    return 0;
    
}