Solution to Merge Sorted List from Jobdu

8 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1519

Question Name: Merge Sorted List

Question Description: Give two sorted single-linked lists, merge them.

Input: the input might contain multiple test cases. Inside each test case, the first line includes two interger N and M (0 <= N, M <= 1000), saying the size of the first and second lists respectively. The second line includes N integers, as the value of each node in the first list. The thid line includes M integers for the second list.

Output: “NULL” if merged list is empty. Otherwise, print out the merged list..

The output matters a lot in the OJ system. A recursive toString() will lead to Time Limit Exceed.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!