Description
An attendance record is a string with only L, A, P characters. A student could be rewarded if there is at most one A and no more than two continuous L's. Given n, return the number of possible attendance records of length n that make a student eligible for reward.
Examples
Input:
n = 2Output:
8Explanation:
PP, AP, PA, LP, PL, AL, LA, LL are valid.
Input:
n = 1Output:
3Explanation:
For length 1, the valid records are P, A, and L. All three satisfy the constraints: at most one A and no more than two continuous L's.
Input:
n = 3Output:
19Explanation:
For length 3, all valid combinations must be counted. Invalid records include those with 2+ A's (like AAP, AAL) or 3+ continuous L's (LLL). Valid records include PPP, PPA, PAP, APP, PLP, LPP, and others. The total count is 19.
Constraints
- •
1 ≤ n ≤ 10^5