https://leetcode.com/problems/student-attendance-record-i/description/
Solution 1.
bool checkRecord(string s) {
int A = 0;
int L = 0;
for(int i=0; i<s.size(); i++) {
if(s[i] == 'A') { A++; if(A==2) return false;}
if(s[i] == 'L') {
L++;
if(L==3) return false;
continue;
}
L = 0;
}
return true;
}
No comments:
Post a Comment