Merge Sorted Queues

Imagine two queues of numbers where each queue is already sorted in ascending order. Given two sorted lists l1 and l2, merge them into one new list that is also sorted in ascending order. This is a classic technique used in sorting algorithms and data stream processing.

Примеры

Ввод
[1, 2, 4], [1, 3, 4]
Вывод
[1, 1, 2, 3, 4, 4]
Ввод
[], []
Вывод
[]
Ввод
[], [0]
Вывод
[0]

Нужно реализовать

def merge_two_lists(l1: list[int], l2: list[int]) -> list[int]:

Теги

liststwo-pointerssorting
PostgreSQLv16

Hier verschijnt het resultaat van je code

Visible tests
1
Input
[1,2,4], [1,3,4]
Expected[1,1,2,3,4,4]
2
Input
[], []
Expected[]
3
Input
[], [0]
Expected[0]
4
Input
[5], [1,2,3]
Expected[1,2,3,5]
5
Input
[1,1,1], [1,1]
Expected[1,1,1,1,1]
6
Input
[1,2,4], []
Expected[1,2,4]
Focus radio
Paused · SomaFM · Fluid