标签:
很简单
public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode h = new ListNode(-1); ListNode l3 = h; while(l1!=null && l2!=null){ if(l1.val < l2.val){ l3.next = l1; l3 = l3.next; l1 = l1.next; }else{ l3.next = l2; l3 = l3.next; l2 = l2.next; } } if(l1==null && l2!=null) l3.next = l2; if(l2==null && l1!=null) l3.next = l1; return h.next; } }
标签:
原文地址:http://www.cnblogs.com/jiajiaxingxing/p/4397339.html