
Approach 1
- 단순히 정수의 개수가 1,000,000개 이므로, 리스트 두 개로 탐색하면, 시간 초과가 날 것이라 생각했다
- 해시는 탐색 속도가 O(1)이기 때문에 해시 테이블을 사용하기로 함
Solution 💡
import sys
T = int(sys.stdin.readline().strip())
for _ in range(T):
N = int(sys.stdin.readline().strip())
lst_1 = set(list(map(str, sys.stdin.readline().split())))
M = int(sys.stdin.readline().strip())
lst_2 = list(map(str, sys.stdin.readline().split()))
for i in lst_2:
if i in lst_1:
print(1)
else:
print(0)
'알고리즘' 카테고리의 다른 글
| 99클럽 코테 스터디 9일차 TIL Boj 1707. 이분 그래프 (0) | 2025.01.23 |
|---|---|
| 99클럽 코테 스터디 8일차 TIL Boj 2667. 단지 번호 붙이기 (0) | 2025.01.22 |
| 99클럽 코테 스터디 7일차 TIL Boj 1697. 숨바꼭질 (0) | 2025.01.21 |
| 99클럽 코테 스터디 3일차 TIL Boj 11663. 선분 위의 점 (0) | 2025.01.15 |
| 99클럽 코테 스터디 2일차 TIL Boj 1654. 암기왕 (0) | 2025.01.14 |
