Student Attendance Record
Each character of s is a day: A absent, L late, P present. The student can get an award if both are true:
- Absent (
A) on fewer than 2 days in total. - Never late (
L) on 3 or more days in a row.
Return True if the student gets the award, otherwise False.
Example 1
s "PPALLP"
returns true
One absence, and only two lates in a row.
Example 2
s "PPALLL"
returns false
Three lates in a row.
Constraints
1 <= len(s) <= 30shas onlyA,L,P
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Sum of Digits in TextBeginner
- Truncate SentenceBeginner
- Two String Lists Spell the Same WordBeginner
- Vowel and Consonant TallyBeginner
- Abbreviate Long WordsEasy
- Buddy StringsEasy
- Caesar CipherEasy
- Capitalize Sentence StartsEasy