s4553711
10/24/2017 - 1:57 PM

551.cpp

class Solution {
public:
    bool checkRecord(string s) {
        int countA = 0;
        int countL = 0;
        for(int i = 0; i < s.size(); i++) {
            if (s[i] == 'A') {
                countA++;
                countL = 0;
            } else if(s[i] == 'L') {
                countL++;
            } else {
                countL = 0;
            }
            if (countA > 1 || countL > 2) return false;
        }
        return true;
    }
};