2. Merge Sorted Lists

Company: Epam_23_jan

Difficulty: medium

Problem Statement

Merge Sorted Lists You are given two singly linked lists, list1 and list2 . The values inside each list are already arranged in non-decreasing order. Complete the function merge_sorted_lists(list1, list2) . It receives the head node of each list (a head is empty when its list has no nodes) and must return the head of one linked list that holds every value of both lists, again in non-decreasing order. Every copy of a repeated value is kept. Each node has two fields: data , the integer it stores, and next , the following node (or nothing at the end of the list). Input Format The first line contains an integer n1 , the number of nodes in list1 . Each of the next n1 lines contains one value of list1 , in list order. The next line contains an integer n2 , the number of nodes in list2 . Each of the next n2 lines contains one value of list2 , in list order. The code in the editor reads the input, builds both lists, calls your function and prints the result. Output Format Print the values of t