투포인터 O(n)
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))
ai = 0
bi = 0
answer = []
while 1:
if arr_a[ai] <= arr_b[bi]:
answer.append(arr_a[ai])
ai += 1
else:
answer.append(arr_b[bi])
bi += 1
if ai == N or bi == M:
answer += arr_a[ai:] + arr_b[bi:]
break
print(*answer)
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 2138 전구와 스위치 (0) | 2021.09.13 |
---|---|
[백준][Python] 1965 상자넣기 (0) | 2021.09.12 |
[백준][Python] 1637 날카로운 눈 (0) | 2021.09.11 |
[백준][Python] 9655 돌게임 (0) | 2021.09.10 |
[백준][Python] 6568 귀도 반 로썸은 크리스마스날 심심하다고 파이썬을 만들었다. (0) | 2021.09.10 |