LeetCode 58 Length of Last Word
LeetCode 58 Length of Last Word
int lengthOfLastWord(char* s) { int length=0,falg=0; int n=strlen(s); if(n<=0) return 0; for(int i=n;i>=1;i--) { if(falg==1 && s[i-1]==' ') break; if(s[i-1]!=' ') { falg=1; length++; } } return length; }