Simple C solution in 3ms


  • 0
    D
    bool checkRecord(char* s) {
        int count_A = 0, len = strlen(s);
        if(strstr(s,"LLL")) return false;
        for(int i=0;i<len;i++){
            if(*(s+i)=='A') count_A++;
            if(count_A>1) return false;
        }
        return true;
    }
    

Log in to reply
 

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