Hulu Interview Question

How to merge two sorted linked list

Interview Answer

Anonymous

Feb 12, 2011

There are two sorted linked list a and b. Create two dummy linked list, c and temp. Make temp = c, Generate a loop from 0 to the size of a and b, If a.val > b.val, c point to b and b = b.next, If a.val < b.val, c point to a and a = a.next, If a.val = b.val, c point to a and then b, increase a and b to the next node. After the loop is end, return temp