Simple C++


  • 0
        bool checkRecord(string s) {
            int countA=0;
            int countL=0;
            bool hasNoLLL=true;
            for(int i=0;i<s.size();i++){
                if(s[i]=='A') countA++;
                countL= (s[i]=='L') ? countL+1 : 0;
                if(countL==3) hasNoLLL=false;
            }
            return countA<=1&&hasNoLLL;
        }
    

Log in to reply
 

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