[백준/코틀린] 1920번: 수 찾기
실버 4
링크
풀이
주어진 수가 존재하는지 O(1)로 판단하기 위해 HashSet을 사용합니다.
코드
1
2
3
4
5
6
7
8
9
10
11
12
fun main() = with(StringBuilder()) {
val n = readln().toInt()
val a = readln().split(" ").map { it.toInt() }.toHashSet()
val m = readln().toInt()
readln().split(" ").map { it.toInt() }.forEach {
appendLine(if (it in a) 1 else 0)
}
println(toString())
}
This post is licensed under CC BY 4.0 by the author.