Easy
Quiz
#551 Student Attendance Record I
APPROACH
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.
1 of 4
1:00
What is the optimal approach for this problem?