1. 程式人生 > >551.學生出勤記錄 I(簡單)

551.學生出勤記錄 I(簡單)

給定一個字串來代表一個學生的出勤記錄,這個記錄僅包含以下三個字元:

  1. 'A' : Absent,缺勤
  2. 'L' : Late,遲到
  3. 'P' : Present,到場

如果一個學生的出勤記錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲到),那麼這個學生會被獎賞。

class Solution:
    def checkRecord(self, s):
        """
        :type s: str
        :rtype: bool
        """
        if s.count('A')>1 or 'LLL' in s:
            return False
        return True      (自己完成)

執行用時: 44 ms, 在Student Attendance Record I的Python3提交中擊敗了99.18% 的使用者