```
int lengthOfLastWord(char* s) {
int len=strlen(s);
int count1=0;
int count2=0;
int i=len-1;
for(;i>=0;i--){
if(s[i]!=' '){
count1=i;
break;
}
}
if(i<0){return 0;}
for(;i>=0;i--){
if(s[i]==' '){return count1-i;}
}
return count1+1;
}
```