File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
bona1122/[week6]Set/String_set Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments