We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5c209a9 commit d81301dCopy full SHA for d81301d
551_StudentAttendanceRecord1.swift
@@ -0,0 +1,27 @@
1
+class Solution {
2
+ func checkRecord(_ s: String) -> Bool {
3
+ var absents = 0
4
+ var lates = 0
5
+ var lastRecord: Character = "L"
6
+ for record in s {
7
+ if record == "A" {
8
+ absents += 1
9
+ if absents > 1 {
10
+ return false
11
+ }
12
+ } else if record == "L" {
13
+ if lastRecord == "L" {
14
+ lates += 1
15
+ } else {
16
+ lates = 1
17
18
+
19
+ if lates > 2 {
20
21
22
23
+ lastRecord = record
24
25
+ return true
26
27
+}
0 commit comments