20240818 Finished

This commit is contained in:
jackfiled 2024-08-18 14:49:55 +08:00
parent 02ab7d2066
commit d7a1bd1e1b
2 changed files with 51 additions and 1 deletions

View File

@ -207,4 +207,5 @@ mod p123_best_time_to_buy_and_sell_stock_iii;
mod p188_best_time_to_buy_and_sell_stock_iv;
mod p221_maximal_square;
mod p3117_minimum_sum_of_values_by_dividing_array;
mod p3137_minimum_number_of_operations_to_make_word_k_periodic;
mod p3137_minimum_number_of_operations_to_make_word_k_periodic;
mod p551_student_attendance_record_i;

View File

@ -0,0 +1,49 @@
/**
* [551] Student Attendance Record I
*/
pub struct Solution {}
// submission codes start here
impl Solution {
pub fn check_record(s: String) -> bool {
let s: Vec<char> = s.chars().collect();
let mut late_count = 0;
let mut absent_count = 0;
for c in s {
match c {
'A' => {
absent_count += 1;
late_count = 0;
if absent_count >= 2 {
return false;
}
},
'L' => {
late_count += 1;
if late_count >= 3 {
return false;
}
},
_ => {
late_count = 0;
}
}
}
true
}
}
// submission codes end
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_551() {}
}