[LeetCode]551. Student Attendance Record I
题目
You are given a string representing an attendance record for a student. The record only contains the following three characters:
- ‘A’ : Absent.
- ‘L’ : Late.
- ‘P’ : Present.
A student could be rewarded if his attendance record doesn’t contain more than one ‘A’ (absent) or more than two continuous ‘L’ (late).
You need to return whether the student could be rewarded according to his attendance record.
Example 1:
1 | Input: "PPALLP" |
Example 2:
1 | Input: "PPALLL" |
难度
Easy
方法
对'A'
和'L'
计数,如果'A'
出现的次数>1
,返回False
;如果'L'
连续出现的次数>2
,则返回False
;其他情况返回True
python代码
1 | class Solution(object): |