C Solution


  • 0
    F

    int lengthOfLastWord(char* s) {
    int i,t=0,f=1;
    for(i=0;s[i]!='\0';i++) {
    if(s[i]==' ') f=1;
    else if(f) {
    t=1;
    f=0;
    }
    else t++;
    }
    return t;
    }


  • 0
    F

    int lengthOfLastWord(char* s) {
    int i,t=0,f=1;
    for(i=0;s[i]!='\0';i++) {
    if(s[i]==' ') f=1;
    else if(f) {
    t=1;
    f=0;
    }
    else t++;
    }
    return t;
    }


Log in to reply
 

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