File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 144
144
| 538 | [ Convert BST to Greater Tree] ( https://leetcode.com/problems/convert-bst-to-greater-tree ) | Easy | [ ![ Java] ( assets/java.png )] ( src/ConvertBSTToGreaterTree.java ) [ ![ Python] ( assets/python.png )] ( python/convert_bst_to_greater_tree.py ) |
145
145
| 541 | [ Reverse String II] ( https://leetcode.com/problems/reverse-string-ii ) | Easy | [ ![ Java] ( assets/java.png )] ( src/ReverseStringII.java/ ) [ ![ Python] ( assets/python.png )] ( python/reverse_string_ii.py ) |
146
146
| 543 | [ Diameter of Binary Tree] ( https://leetcode.com/problems/diameter-of-binary-tree ) | Easy | [ ![ Java] ( assets/java.png )] ( src/DiameterOfBinaryTree.java ) [ ![ Python] ( assets/python.png )] ( python/diameter_of_binary_tree.py ) |
147
- | 551 | [ Student Attendance Record I] ( https://leetcode.com/problems/student-attendance-record-i ) | Easy | |
147
+ | 551 | [ Student Attendance Record I] ( https://leetcode.com/problems/student-attendance-record-i ) | Easy | [ ![ Java ] ( assets/java.png )] ( src/StudentAttendanceRecordI.java ) [ ![ Python ] ( assets/python.png )] ( python/student_attendance_record_I.py ) |
148
148
| 557 | [ Reverse Words in a String III] ( https://leetcode.com/problems/reverse-words-in-a-string-iii ) | Easy | |
149
149
| 559 | [ Maximum Depth of N-Ary Tree] ( https://leetcode.com/problems/maximum-depth-of-n-ary-tree ) | Easy | |
150
150
| 561 | [ Array Partition I] ( https://leetcode.com/problems/array-partition-i ) | Easy | |
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def checkRecord (self , s : str ) -> bool :
3
+ consecutiveLate , absent = 0 , 0
4
+ for character in s :
5
+ if character == 'L' :
6
+ consecutiveLate += 1
7
+ else :
8
+ if character == 'A' : absent += 1
9
+ consecutiveLate = 0
10
+ if consecutiveLate >= 3 or absent >= 2 : return False
11
+ return True
Original file line number Diff line number Diff line change
1
+ public class StudentAttendanceRecordI {
2
+ public boolean checkRecord (String s ) {
3
+ int consecutiveLate = 0 , absentees = 0 ;
4
+ for (int index = 0 ; index < s .length () ; index ++) {
5
+ if (s .charAt (index ) == 'L' ) {
6
+ consecutiveLate ++;
7
+ } else {
8
+ if (s .charAt (index ) == 'A' ) absentees ++;
9
+ consecutiveLate = 0 ;
10
+ }
11
+ if (absentees >= 2 || consecutiveLate >= 3 ) {
12
+ return false ;
13
+ }
14
+ }
15
+ return true ;
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments