Hard · Dynamic Programming
Student Attendance Record II
Given n, return how many attendance records of length n over the letters 'A' (absent), 'L' (late) and 'P' (present) are eligible for an award, meaning fewer than 2 'A' in total and never 3 or more consecutive 'L'. Return the count modulo 10⁹ + 7.
Examples
Example 1
n = 2Output: 8 records
Example 2
n = 3Output: 19 records
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.