generate functionWed, 01 Mar 2023

You have two non-decreasing sorted lists of n and m elements Your task is to merge them into one sorted list of size n + m Input The program receives as input two numbers n and m - the number of elements of the first list and the second list Then the elements of the first sorted list come from a new line, and from the next line - the second list Output Merge two lists into one in non-decreasing order and output the elements of the resulting list P.S: it is forbidden to use the built-in sorting Note: to display the resulting list, you can use the following construction print(*result) # where result is the final list

n = int(input()) m = int(input()) a = [int(input()) for _ in range(n)] b = [int(input()) for _ in range(m)] c = a + b for i in range(len(c)): m = min(c) print(m, end=' ') c.remove(m) print()

Questions about programming?Chat with your personal AI assistant