题解 | #合并两个排序的链表#

合并两个排序的链表

http://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337

function ListNode(x){
    this.val = x;
    this.next = null;
}
function Merge(pHead1, pHead2)
{
    // write code here
    if (!pHead1  ) return pHead2;
    if (!pHead2  ) return pHead1;
    if(pHead1.val <= pHead2.val){
        pHead1.next = Merge(pHead1.next, pHead2);
        return pHead1
    }else{
        pHead2.next = Merge(pHead2.next, pHead1);
        return pHead2
    }

}
module.exports = {
    Merge : Merge
};
全部评论

相关推荐

后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 18:25
点赞 评论 收藏
分享
评论
14
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务