首页 > 其他分享 >leetcode-551. 学生出勤记录 I

leetcode-551. 学生出勤记录 I

时间:2022-12-30 12:55:12浏览次数:52  
标签:cLateCnt return 出勤 551 ++ absentCnt leetcode

551. 学生出勤记录 I - 力扣(Leetcode)

字符串序列计数

func checkRecord(s string) bool {
    absentCnt := 0
    cLateCnt := 0

    for i := 0; i < len(s); i++ {
        v := s[i]
        if uint8(v) == 'A' {
            absentCnt ++
            cLateCnt = 0
        } else if uint8(v) == 'L' {
            cLateCnt ++
        } else {
            cLateCnt = 0
        }

        if cLateCnt >= 3 {
            return false
        }
    }

    if absentCnt >= 2 {
        return false
    }

    return true
}

标签:cLateCnt,return,出勤,551,++,absentCnt,leetcode
From: https://www.cnblogs.com/wudanyang/p/17014650.html

相关文章