题解 | #4.合并两个排序的链表#
合并两个排序的链表
http://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337
so esay
function Merge(pHead1, pHead2)
{
let empty = {};
let pre = empty;
while(pHead1!=null && pHead2!=null){
if(pHead1.val < pHead2.val){
pre.next = pHead1;
pHead1 = pHead1.next;
}else{
pre.next = pHead2;
pHead2 = pHead2.next;
}
pre = pre.next;
}
pre.next = pHead1!=null ? pHead1 : pHead2;
return empty.next
}