551. Student Attendance Record I Easy

@problem@discussion
#String



1/**
2 * [551] Student Attendance Record I
3 *
4 * You are given a string s representing an attendance record for a student 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 * The 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 * Return true if the student is eligible for an attendance award, or false otherwise.
16 *  
17 * Example 1:
18 * 
19 * Input: s = "PPALLP"
20 * Output: true
21 * Explanation: The student has fewer than 2 absences and was never late 3 or more consecutive days.
22 * 
23 * Example 2:
24 * 
25 * Input: s = "PPALLL"
26 * Output: false
27 * Explanation: The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	1 <= s.length <= 1000
33 * 	s[i] is either 'A', 'L', or 'P'.
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/student-attendance-record-i/
39// discuss: https://leetcode.com/problems/student-attendance-record-i/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn check_record(s: String) -> bool {
45        false
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_551() {
57    }
58}
59


Back
© 2025 bowen.ge All Rights Reserved.