20240818 Finished
This commit is contained in:
		@@ -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 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;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										49
									
								
								src/problem/p551_student_attendance_record_i.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/problem/p551_student_attendance_record_i.rs
									
									
									
									
									
										Normal 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() {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user