题解 | #反转链表#

反转链表

http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca

/function ListNode(x){ this.val = x; this.next = null; }/ function ReverseList(pHead) { // write code here

if(pHead==null||pHead.next==null){
    return pHead
}

let pre=null,cur=pHead
while(cur){
    let temp=cur.next
    cur.next=pre
    pre=cur
    cur=temp
}
return pre

} module.exports = { ReverseList : ReverseList }; https://www.bilibili.com/video/BV1KZ4y157Up

全部评论

相关推荐

不愿透露姓名的神秘牛友
05-09 15:06
求好运眷顾🙏🏻:翻译:面试前没盘点好hc一下面太多了,现在在排序回去等通知
点赞 评论 收藏
分享
04-17 23:48
西北大学 Java
陈好好wy:加油加油 字节和心脏谁先跳动
字节跳动开奖383人在聊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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