File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ # You are given a string representing an attendance record for a student.
2
+ # The record only contains the following three characters:
3
+ # 'A' : Absent.
4
+ # 'L' : Late.
5
+ # 'P' : Present.
6
+ # A student could be rewarded if his attendance record doesn't contain
7
+ # more than one 'A' (absent) or more than two continuous 'L' (late).
8
+ #
9
+ # You need to return whether the student could be rewarded according to his attendance record.
10
+ #
11
+ # Example 1:
12
+ #
13
+ # Input: "PPALLP"
14
+ # Output: True
15
+ # Example 2:
16
+ #
17
+ # Input: "PPALLL"
18
+ # Output: False
19
+
20
+
21
+ class Solution :
22
+ def checkRecord (self , s ):
23
+ countA = 0
24
+
25
+ for i in range (len (s )):
26
+ if s [i ] == 'A' :
27
+ countA += 1
28
+ if (i < len (s ) - 2 ) and s [i ] == 'L' and s [i + 1 ] == 'L' and s [i + 2 ] == 'L' :
29
+ return False
30
+
31
+ if countA > 1 :
32
+ return False
33
+ return True
You can’t perform that action at this time.
0 commit comments