Merging Sorted Arrays · Compiler
Merging Sorted Arrays
Merge two arrays sorted in nondecreasing order into one sorted sequence. Keep every occurrence of each value.
- Input
- Line 1 contains the lengths n and m (0 to 100 each). The remaining whitespace-separated integers are the n values of the first array followed by the m values of the second. Each value is from -1000 to 1000. Each array is sorted in nondecreasing order and n + m is at least 1.
- Output
- Print the merged values in nondecreasing order on one line, separated by spaces.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…