https://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337
非递归
之前好像在《算法笔记》上做过,是某种排序算法思想?
public ListNode Merge(ListNode list1, ListNode list2) {ListNode head = new ListNode(0);ListNode node = head;while (list1 != null && list2 != null) {if (list1.val <= list2.val) {node.next = list1;node = list1;list1 = list1.next;} else {node.next = list2;node = list2;list2 = list2.next;}}while (list2 != null) {node.next = list2;node = list2;list2 = list2.next;}while (list1 != null) {node.next = list1;node = list1;list1 = list1.next;}return head.next;}
