#551
Student Attendance Record I
pupil · 445 · lc easy +26 · verified · 50% accepted · 855 likes · top 38%
Description
A student's attendance record s uses three characters per day:
- 'A': Absent.
- 'L': Late.
- 'P': Present.
The student earns an attendance award only when both conditions hold:
- Fewer than 2 total absences ('A').
- No run of 3 or more consecutive late days ('L').
Return true if the student qualifies, or false otherwise.
Example 1:
Input: s = "PPALLP"
Output: true
Explanation: The student has fewer than 2 absences and was never late 3 or more consecutive days.
Example 2:
Input: s = "PPALLL"
Output: false
Explanation: The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.
Code
1
2
3