Skip to content

Commit 23a6ab4

Browse files
committed
[Hash] baekjoon-1764
1 parent ddc6027 commit 23a6ab4

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
| 25 | | [Baekjoon-17779 게리맨더링 2](./src/Simulation/P17779) | |
6565
| 26 | | [Baekjoon-2564 경비원](./src/Simulation/P2564) | |
6666
| 27 | | [Baekjoon-17144 미세먼지 안녕!](./src/Simulation/P17144) | |
67-
| 28 | | [SWEA-5656 벽돌 깨기](./src/Simulation/swea5656) | |
67+
| 28 | ⭐️ | [SWEA-5656 벽돌 깨기](./src/Simulation/swea5656) | |
6868

6969
## String
7070

@@ -258,6 +258,7 @@
258258
| # || Problem | Note |
259259
| :-: | :-: | :----------------------------------------- | :--- |
260260
| 01 | | [Programmers 베스트앨범](./src/Hash/prg42579) | |
261+
| 02 | | [Baekjoon-1764 듣보잡](./src/Hash/P1764) | |
261262

262263
## Graph
263264

src/Hash/P1764/Main.java

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package Hash.P1764;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class Main {
7+
8+
static int N, M;
9+
static HashMap<String, Integer> map = new HashMap<>();
10+
static List<String> list = new ArrayList<>();
11+
12+
public static void main(String[] args) throws Exception {
13+
System.setIn(new FileInputStream("src/Hash/P1764/input.txt"));
14+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
15+
StringTokenizer st = new StringTokenizer(br.readLine());
16+
17+
N = Integer.parseInt(st.nextToken());
18+
M = Integer.parseInt(st.nextToken());
19+
20+
for (int i = 0; i < N+M; i++) {
21+
map.merge(br.readLine(), 1, Integer::sum);
22+
}
23+
24+
map.forEach((key, value) -> {
25+
if (value == 2) list.add(key);
26+
});
27+
28+
list.sort(String::compareTo);
29+
System.out.println(list.size());
30+
for (String s : list) System.out.println(s);
31+
}
32+
}

src/Hash/P1764/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [baekjoon-1764] 듣보잡
2+
3+
![image](https://user-images.githubusercontent.com/22045163/115133913-acab6280-a046-11eb-89ff-4b14483bb6c0.png)
4+
5+
![image](https://user-images.githubusercontent.com/22045163/115133921-b339da00-a046-11eb-8473-6d78f9918321.png)

src/Hash/P1764/input.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
3 4
2+
ohhenrie
3+
charlie
4+
baesangwook
5+
obama
6+
baesangwook
7+
ohhenrie
8+
clinton

0 commit comments

Comments
 (0)