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
- Class
- sorting
- Data Structure
- Binary Tree
- Counting
- Number Theory
- bit manipulation
- 구현
- greedy
- simulation
- database
- 코테
- java
- dynamic programming
- string
- 코딩테스트
- Tree
- geometry
- array
- hash table
- Math
- SQL
- 파이썬
- Binary Search
- 자바
- Matrix
- implement
- Stack
- two pointers
- Method
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2678. Number of Senior Citizens 본문
1. Input
1) String[] details
2. Output
1) 주어진 정보를 보고 나이가 60세보다 많은 승객의 수를 반환
- details[i]는 i번째 승객의 정보를 나타낸 길이 15의 문자열이다.
- 첫 10문자는 폰 번호를 나타낸다.
- 그 다음 문자는 성별을 나타낸다.
- 그 다음 2문자는 나이를 나타낸다.
- 마지막 2문자는 좌석 번호를 나타낸다.
3. Constraint
1) 1 <= details.length <= 100
2) details[i].length == 15
3) 성별은 'M', 'F', 'O'로 나타낸다.
4) 나머지 문자는 0~9 사이의 숫자이다.
5) 승객의 폰 번호와 좌석 번호는 중복을 허용하지 않는다.
4. Example
Input: details = ["7868190130M7522","5303914400F9211","9273338290F4010"] -> Output: 2
설명: 각 승객의 나이는 75, 92, 40이므로 2를 반환한다.
5. Code
1) 첫 코드(2023/06/29)
class Solution {
public int countSeniors(String[] details) {
int count = 0;
for(int i=0 ; i<details.length ; i++){
if(details[i].charAt(11)>'6')
count++;
else if(details[i].charAt(11)=='6' && details[i].charAt(12)>'0')
count++;
}
return count;
}
}
- 84%, 97%
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2696. Minimum String Length After Removing Substrings (0) | 2023.06.30 |
---|---|
[LeetCode/Easy] 2682. Find the Losers of the Circular Game (0) | 2023.06.29 |
[LeetCode/Easy] 2660. Determine the Winner of a Bowling Game (0) | 2023.06.29 |
[백준 온라인 저지] 2812. 크게 만들기 (0) | 2023.06.29 |
[백준 온라인 저지] 1969. DNA (0) | 2023.06.29 |