题目:输入两个递增排序的链表,合并这两个链表并使新链表中的节点依然是排序的
public class MergeNode {
public ListNode Merge(ListNode pHead1,ListNode pHead2){
if(pHead1==null) return pHead2;
if(pHead2==null) return pHead1;
ListNode pMergeNode = null;
if(pHead1.val<pHead2.val){
pMergeNode = pHead1;
pMergeNode.next = Merge(pHead1.next,pHead2);
}
else{
pMergeNode=pHead2;
pMergeNode.next=Merge(pHead1,pHead2.next);
}
return pMergeNode;
}
}