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
- 공개키 암호화
- 자료구조
- dbms
- 코테
- jsp
- DB
- generic class
- 코딩테스트준비
- 코딩테스트
- 위상정렬
- sql
- python
- mysql
- 항해99
- 99클럽
- 크루스칼
- til
- 개발자취업
- 정렬
- 99클럽 #코딩테스트준비 #개발자취업 #항해99 #til
- 알고리즘
- Sort
- js
- LeetCode
- Java
- javascript
- 가상컴퓨팅
- JPA
- Algorithm
- spring
Archives
- Today
- Total
PLOD
[백준] 파일 정리(20291) 본문
🔗 문제 링크
https://www.acmicpc.net/problem/20291
✅ 코드
import java.io.*;
import java.util.*;
public class 백준_20291 {
static int n;
static HashMap<String,Integer> files;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
files = new HashMap<>();
while(n --> 0){
st = new StringTokenizer(br.readLine());
String[] fileName = st.nextToken().split("\\.");
files.put(fileName[1], files.getOrDefault(fileName[1],0) + 1);
}
ArrayList<String> list = new ArrayList<>(files.keySet());
Collections.sort(list);
for(String x : list){
System.out.println(x + " " + files.get(x));
}
br.close();
}
}
💡 배운 점 & 느낀 점
1. String[] fileName = st.nextToken()..split("\\."); → "."과 같은 경우 정규식(regex) 기반 이기 때문에 "\\."로 해주어야 함
2. HashMap<Key,Value>() → Key에 get으로 Value 접근 가능
'대외 활동 및 IT 지식 > 알고리즘 문제 풀이 정리' 카테고리의 다른 글
| [Leetcode] 2283. Check if Number Has Equal Digit Count and Digit Value (0) | 2026.03.20 |
|---|---|
| [백준] 좌표 압축(18870) (0) | 2026.03.09 |
| [백준] 식당 메뉴(26043) (0) | 2026.02.25 |
| [백준] 큐(10843) (0) | 2026.02.22 |
| [백준] 스택(10828) (0) | 2026.02.22 |
Comments