9ms accepted C


  • 0
    J

    int firstUniqChar(char* s){
    long long a[256] = {0};
    char*p = s;
    while(*p) a[*p++]++;
    p = s;
    while(*s){
    if(a[*s] == 1) break;
    s++;
    }
    return *s?s-p:-1;
    }


Log in to reply
 

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