题解 | #二叉树的最大深度#

合并两个排序的链表

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 } let head if(pHead1.val < pHead2.val) { head = pHead1 head.next = Merge(pHead1.next,pHead2) } else { head = pHead2 head.next = Merge(pHead2.next,pHead1) } return head } module.exports = { Merge : Merge };

全部评论

相关推荐

06-11 13:34
门头沟学院 C++
offe从四面八方来:我真的没时间陪你闹了
点赞 评论 收藏
分享
仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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