3ms C solution


  • 1
    L
    int lengthOfLastWord(char* s) {
        int i,count=0;
        for(i=strlen(s)-1;i>=0;i--)
        {
        	if(s[i]==' ' && count!=0)
        	    break;
        	if(s[i]!=' ' || count!=0)
        	    count++;
        }
        return count;
    }
    

Log in to reply
 

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