3ms solution in C


  • 0
    B
    bool checkRecord(char* s) {
        int i = 0, anum = 0, lnum = 0, size = strlen(s);
        for( ; i < size; i++)
        {
            switch(*(s + i))
            {
                case 'A': anum++; lnum = 0; break;
                case 'L': lnum++; break;
                case 'P': lnum = 0; break;
            }
            if(anum == 2 || lnum == 3)
            {
                return false;
            }
        }
        return true;
    }
    

Log in to reply
 

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