Golang | Leetcode Golang题解之第551题学生出勤记录I
题目:
题解:
func checkRecord(s string) bool {
absents, lates := 0, 0
for _, ch := range s {
if ch == 'A' {
absents++
if absents >= 2 {
return false
}
}
if ch == 'L' {
lates++
if lates >= 3 {
return false
}
} else {
lates = 0
}
}
return true
}