Skip to content

Commit 198e580

Browse files
committed
88차 2번 문제 풀이
1 parent f86ca32 commit 198e580

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

live8/test88/문제2/박희경.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, m = map(int, input().split())
6+
a = list(map(int, input().split()))
7+
b = list(map(int, input().split()))
8+
9+
res = []
10+
i, j = 0, 0
11+
while i < n and j < m:
12+
if a[i] == b[j]:
13+
res.append(a[i])
14+
res.append(b[j])
15+
i += 1
16+
j += 1
17+
elif a[i] < b[j]:
18+
res.append(a[i])
19+
i += 1
20+
else:
21+
res.append(b[j])
22+
j += 1
23+
24+
# 한쪽은 다 탐색했는데 한 쪽은 남았을 경우
25+
while i < n:
26+
res.append(a[i])
27+
i += 1
28+
while j < m:
29+
res.append(b[j])
30+
j += 1
31+
32+
print(*res)

0 commit comments

Comments
 (0)