Python•student-attendance-record-i/synced-solution.py
class Solution:
def checkRecord(self, s: str) -> bool:
return s.count(class="syntax-string">"A") < class="syntax-number">2 and class="syntax-string">"LLL" not in s
C++•student-attendance-record-i/synced-solution.cpp
class Solution {
public:
bool checkRecord(string s) {
int absences = class="syntax-number">0;
int consecutiveLate = class="syntax-number">0;
for (char c : s) {
if (c == class="syntax-string">'A') {
absences++;
consecutiveLate = class="syntax-number">0;
if (absences >= class="syntax-number">2) {
return false;
}
} else if (c == class="syntax-string">'L') {
consecutiveLate++;
if (consecutiveLate >= class="syntax-number">3) {
return false;
}
} else {
consecutiveLate = class="syntax-number">0;
}
}
return true;
}
};
TypeScript•student-attendance-record-i/synced-solution.ts
function checkRecord(s: string): boolean {
let absences = class="syntax-number">0;
let consecutiveLate = class="syntax-number">0;
for (const ch of s) {
if (ch === class="syntax-string">"A") {
absences++;
consecutiveLate = class="syntax-number">0;
if (absences >= class="syntax-number">2) {
return false;
}
} else if (ch === class="syntax-string">"L") {
consecutiveLate++;
if (consecutiveLate >= class="syntax-number">3) {
return false;
}
} else {
consecutiveLate = class="syntax-number">0;
}
}
return true;
}