https://oj.leetcode.com/problems/merge-two-sorted-lists/
http://blog.csdn.net/linhuanmars/article/details/19712593
/** * definition for singly-linked list. * public class listnode { * int val; * ListNode Next; * listnode (int x) { * val = x; * next = null; * } * } */public class solution { public listnode mergetwolists (LISTNODE&NBSP;L1,&NBSP;LISTNODE&NBSP;L2 ) { if (l1 == null && l2 == NULL) return null; listnode toreturn = null; ListNode curNode = null; ListNode lastNode = null; while (l1 != null | | l2 != null) { // Select current node; if (l1 == null) { curNode = l2; l2 = l2.next; &nbsP; } else if (l2 == null) { curnode = l1; l1 = l1.next; } else if (L1.val < l2.val) { curNode = l1; l1 = l1.next; &nbsP; } else { curNode = l2; l2 = l2.next; } if ( Toreturn == null) toReturn = curNode; if (lastnode != null) lastnode.next = curnode; lastNode = curNode; } return toreturn; }}
[Leetcode]21 Merge Sorted Lists