Arrays · 22 / 23 Exercise Hard

Merge two sorted lists

Objective

If two lists are already sorted, they can be merged into a single sorted one by walking through both with two indexes, without sorting everything again. It is the basis of merge sort.

Instructions

  • Read two lines, each with integers already sorted in ascending order and separated by spaces (they may be empty).
  • Show the sorted merge, separated by spaces. Do not use sorted or sort: walk both lists with indexes.
Input
1 4 6
2 3 9
Output
1 2 3 4 6 9

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise