552. Student Attendance Record II Hard

@problem@discussion
#Dynamic Programming



1/**
2 * [552] Student Attendance Record II
3 *
4 * An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:
5 * 
6 * 	'A': Absent.
7 * 	'L': Late.
8 * 	'P': Present.
9 * 
10 * Any student is eligible for an attendance award if they meet both of the following criteria:
11 * 
12 * 	The student was absent ('A') for strictly fewer than 2 days total.
13 * 	The student was never late ('L') for 3 or more consecutive days.
14 * 
15 * Given an integer n, return the number of possible attendance records of length n that make a student eligible for an attendance award. The answer may be very large, so return it modulo 10^9 + 7.
16 *  
17 * Example 1:
18 * 
19 * Input: n = 2
20 * Output: 8
21 * Explanation: There are 8 records with length 2 that are eligible for an award:
22 * "PP", "AP", "PA", "LP", "PL", "AL", "LA", "LL"
23 * Only "AA" is not eligible because there are 2 absences (there need to be fewer than 2).
24 * 
25 * Example 2:
26 * 
27 * Input: n = 1
28 * Output: 3
29 * 
30 * Example 3:
31 * 
32 * Input: n = 10101
33 * Output: 183236316
34 * 
35 *  
36 * Constraints:
37 * 
38 * 	1 <= n <= 10^5
39 * 
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/student-attendance-record-ii/
44// discuss: https://leetcode.com/problems/student-attendance-record-ii/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49    pub fn check_record(n: i32) -> i32 {
50        0
51    }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58    use super::*;
59
60    #[test]
61    fn test_552() {
62    }
63}
64


Back
© 2025 bowen.ge All Rights Reserved.