Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 캐치카페
- programmers
- github
- dacon
- Baekjoon
- Kaggle
- ChatGPT
- Git
- 더현대서울 맛집
- 편스토랑 우승상품
- PYTHON
- 백준
- ubuntu
- leetcode
- hackerrank
- 금융문자분석경진대회
- 코로나19
- 데이콘
- 프로그래머스
- 파이썬
- Real or Not? NLP with Disaster Tweets
- 자연어처리
- 우분투
- Docker
- AI 경진대회
- 편스토랑
- 프로그래머스 파이썬
- gs25
- SW Expert Academy
- 맥북
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 551. Student Attendance Record I (Python) 본문
728x90
반응형

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:
Input: "PPALLP"
Output: True
Example 2:
Input: "PPALLL"
Output: False
Solution
from collections import Counter
class Solution:
def checkRecord(self, s: str) -> bool:
answer = True
a_count = 0
for i in range(len(s)):
if s[i] == 'A':
a_count = a_count + 1
if a_count == 2:
answer = False
break
elif s[i] == 'L' and i+2 < len(s):
if s[i+1] == 'L' and s[i+2] == 'L':
answer = False
break
return answer



SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
| [leetCode] 392. Is Subsequence (Python) (0) | 2020.08.13 |
|---|---|
| [leetCode] 916. Word Subsets (Python) (0) | 2020.08.09 |
| [leetCode] 345. Reverse Vowels of a String (Python) (0) | 2020.08.07 |
| [leetCode] 448. Find All Numbers Disappeared in an Array (Python) (0) | 2020.08.06 |
| [leetCode] 35. Search Insert Position (Python) (0) | 2020.08.05 |
Comments