20240818 Finished

This commit is contained in:
jackfiled 2024-08-18 14:48:53 +08:00
parent 02ab7d2066
commit ea718eff4c
3 changed files with 75 additions and 1 deletions

24
TEST Normal file
View File

@ -0,0 +1,24 @@
1. Move the cursor to this line.
2. Press [v](v) and move the cursor to the fifth item below. Notice that the
text is highlighted.
3. Press the `:`{normal} character. At the bottom of the screen
`:'<,'>`{vim}
will appear.
4. Type
`w TEST`{vim}
where TEST is a filename that does not exist yet. Verify that you see
`:'<,'>w TEST`{vim}
before you press `<Enter>`{normal}.
5. Neovim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it.
Do not remove it yet! We will use it in the next lesson.

View File

@ -208,3 +208,4 @@ mod p188_best_time_to_buy_and_sell_stock_iv;
mod p221_maximal_square; mod p221_maximal_square;
mod p3117_minimum_sum_of_values_by_dividing_array; 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() {}
}