C++ very simple solution


  • 15
    M
    bool checkRecord(string s) {
        int a=0, l=0;
        for(int i=0;i<s.size();i++) {
            if(s[i]=='A') a++;
            if(s[i]=='L') l++;
            else l=0;
            if(a>=2||l>2) return false;
        }
        return true;
    }

  • 0
    I

    完美运用了if-else结构,厉害!


Log in to reply
 

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