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 = 2

Output: 8 records

Example 2

n = 3

Output: 19 records

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Dynamic Programming problems