Tap here to switch tabs
Problem
Submissions

Problem: Student Attendance Record II

med
30 min
Try to solve the Student Attendance Record II problem.

Statement

An attendance record for a student is represented as a string where each character denotes the attendance status for a single day:

  • 'A': Absent.

  • 'L': Late.

  • 'P': Present.

A student is eligible for an attendance award if their record satisfies both of the following criteria:

  • The student was absent strictly fewer than 22 days (strictly fewer than 22 'A' characters in total).

  • The student was never late for 33 or more consecutive days (no substring of 33 or more consecutive 'L' characters).

Given an integer n, return the number of possible attendance records of length n that make a student eligible for an award. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Student Attendance Record II

med
30 min
Try to solve the Student Attendance Record II problem.

Statement

An attendance record for a student is represented as a string where each character denotes the attendance status for a single day:

  • 'A': Absent.

  • 'L': Late.

  • 'P': Present.

A student is eligible for an attendance award if their record satisfies both of the following criteria:

  • The student was absent strictly fewer than 22 days (strictly fewer than 22 'A' characters in total).

  • The student was never late for 33 or more consecutive days (no substring of 33 or more consecutive 'L' characters).

Given an integer n, return the number of possible attendance records of length n that make a student eligible for an award. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5