Monday, January 2, 2023
func checkRecord(s string) bool {
consLateCount := 0
absentCount := 0
result := true
for _, rune := range s {
if string(rune) == "L" {
consLateCount++
} else {
consLateCount = 0
}
if string(rune) == "A" {
absentCount++
}
if consLateCount > 2 || absentCount > 1 {
result = false
break
}
}
return result
}