Java solution


  • 0
    D
    class Solution
    {
        public int lengthOfLastWord(String s) 
        {
            int num = s.length() ;
            int count=0 ;
              
            count=num-(s.indexOf(" ")+1);
        
            return count;
        }
    }
    

Log in to reply
 

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