-
46. Student Attendance Record IProblem Solving 2022. 12. 31. 21:25728x90
https://leetcode.com/problems/student-attendance-record-i/
Student Attendance Record I - LeetCode
Student Attendance Record I - You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: * '
leetcode.com
연속 3번 지각 or 전체 중 2번 이상 결석은 False, 나머지는 True 리턴
class Solution: def checkRecord(self, s: str) -> bool: absent = 0 late = 0 for i in s: if i == 'A': absent = absent + 1 if absent >= 2: return False if i == 'L': late = late + 1 if late >= 3: return False else: late = 0 return True
'Problem Solving' 카테고리의 다른 글
48. 농구 게임 (0) 2022.12.31 47. 단어 공부 (0) 2022.12.31 45. Backspace String Compare (0) 2022.12.31 44. JadenCase 문자열 만들기 (0) 2022.12.31 43. Detemine if String Halves Are Alike (0) 2022.12.31