题目:
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
题目意思:拼接连个链表成一个新链表,新链表应该由两个链表中的较小首结点开始,按顺序依次排下去;
解题思路:
创建一个头结点;将其赋值给一个新结点,比较两个链表结点大小,让新节点指向较小结点,依次循环,最后让其指向非空链表,返回头结点的next;
代码如下: