We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4d3e43b commit a716608Copy full SHA for a716608
problems/student_attendance_record_i/solution.rs
@@ -0,0 +1,41 @@
1
+ impl Solution {
2
+ pub fn check_record(s: String) -> bool {
3
+ let mut absents = 0;
4
+ let mut conseq_late = 0;
5
+ let mut late_last = false;
6
+ for c in s.chars() {
7
+ match c {
8
+ 'A' => {
9
+ if absents == 1 {
10
+ return false;
11
+ } else {
12
+ absents += 1;
13
+ late_last = false;
14
+ conseq_late = 0;
15
+ }
16
17
+ 'L' => {
18
+ // We always add one if there are none
19
+ if conseq_late == 0 {
20
+ conseq_late += 1;
21
22
+ if late_last {
23
24
25
+ if conseq_late == 3 {
26
27
28
+
29
+ late_last = true;
30
31
+ 'P' => {
32
33
34
35
+ _ => unreachable!(),
36
37
38
39
+ return true;
40
41
0 commit comments