dsa · easy
Attendance Reward
s is an attendance string of A (absent), L (late), and P (present). A student earns the reward when both of these hold:
Arguments
s— attendance string of A, L, and P
Aappears **strictly fewer than twice**- there are never **three or more**
Lin a row
Return whether the student earns the reward.
Example
s = "PPALLP" has one A and the longest late run is LL (length 2) → true.
s = "PPALLL" still has one A, but LLL is three lates in a row → false.
s = "AA" has two absences → false.
Constraints
1 <= s.length <= 1000 s consists of A, L, and P only Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: "PPALLP" Expected: true
Example 2
Input: "PPALLL" Expected: false
Example 3
Input: "AA" Expected: false