Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Matrix
- Counting
- 코딩테스트
- array
- 파이썬
- Method
- sorting
- simulation
- greedy
- two pointers
- Number Theory
- Math
- 코테
- Stack
- Tree
- SQL
- java
- database
- geometry
- Data Structure
- Binary Tree
- hash table
- bit manipulation
- Class
- 구현
- Binary Search
- 자바
- implement
- dynamic programming
- string
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 551. Student Attendance Record I 본문
1. Input
1) 문자열 s
- ‘A’는 결석, ‘L’은 지각, ‘P’는 출석을 의미
2. Output
1) 이 학생이 정근상을 받을 자격이 있다면 true, 없다면 false를 반환
- 결석이 2번 이상이거나, 지각을 3일 이상 연속으로 한다면 자격이 없다.
3. Constraint
1) 1 <= s.length <= 1000
2) s는 ‘A’, ‘L’, ‘P’로만 이루어져 있다.
4. Example
Input: s = "PPALLP" -> Output: true
Input: s = "PPALLL" -> Output: false
5. Code
1) 첫 코드(2022/12/26)
boolean answer = true;
if(s.contains("LLL"))
answer = false;
else{
int absent = 0;
for(int i=0 ; i<s.length() ; i++){
if(s.charAt(i)=='A') absent++;
if(absent>=2){
answer = false; break;
}
} // for i
} // else
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1507. Reformat Date (0) | 2022.12.27 |
---|---|
[LeetCode/Easy] 1502. Can Make Arithmetic Progression From Sequence (0) | 2022.12.27 |
[LeetCode/Medium] 28. Find the Index of the First Occurrence in a String (0) | 2022.12.26 |
[LeetCode/Medium] 215. Kth Largest Element in an Array (0) | 2022.12.26 |
[LeetCode/Easy] 1491. Average Salary Excluding the Minimum and Maximum Salary (0) | 2022.12.26 |