Skip to content

Commit 248d885

Browse files
committed
String set / 심화
1 parent 576c5df commit 248d885

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// https://www.acmicpc.net/problem/14425
2+
3+
const filePath =
4+
process.platform === "linux"
5+
? "/dev/stdin"
6+
: require("path").join(__dirname, "input.txt")
7+
const input = require("fs").readFileSync(filePath).toString().trim().split("\n")
8+
const log = console.log
9+
10+
const [N, M] = input[0].split(" ").map(Number)
11+
const S = new Set() // 집합 S를 Set으로 만듭니다
12+
13+
// N개의 문자열을 집합 S에 추가
14+
for (let i = 1; i <= N; i++) {
15+
S.add(input[i])
16+
}
17+
18+
let count = 0
19+
// M개의 문자열 각각이 집합 S에 포함되어 있는지 확인
20+
for (let i = N + 1; i <= N + M; i++) {
21+
if (S.has(input[i])) count++
22+
}
23+
24+
log(count)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
5 11
2+
baekjoononlinejudge
3+
startlink
4+
codeplus
5+
sundaycoding
6+
codingsh
7+
baekjoon
8+
codeplus
9+
codeminus
10+
startlink
11+
starlink
12+
sundaycoding
13+
codingsh
14+
codinghs
15+
sondaycoding
16+
startrink
17+
icerink

0 commit comments

Comments
 (0)