practivceAlgorithm/백준
[백준][Python] 11728 배열합치기
findTheValue
2021. 9. 12. 18:57
투포인터 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)