forked from yingl/LintCodeInPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattendance-judgment.py
More file actions
30 lines (29 loc) · 817 Bytes
/
attendance-judgment.py
File metadata and controls
30 lines (29 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Solution:
"""
@param record: Attendance record.
@return: If the student should be punished return true, else return false.
"""
def judge(self, record):
# Write your code here.
cd, cl = 0, 0
pl = None
for c in record:
if c == 'D':
cd += 1
if cd == 2:
return True
pl = None
cl = 0
elif c == 'L':
if pl != 'L':
pl = 'L'
cl += 1
else:
cl += 1
if cl == 3:
return True
else:
pl = None
cl = 0
return False
# easy: https://www.lintcode.com/problem/attendance-judgment/