题解 | #反转链表#

反转链表

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

全部评论

相关推荐

07-11 11:10
门头沟学院 Java
请问各位大三兄弟们跟hr说多久实习时间到时候可以提前跑路吗?
程序员小白条:问就是六个月以上,可以一年,实习都这样,你入职后想跑就跑
点赞 评论 收藏
分享
06-02 15:17
门头沟学院 Java
心爱的idea:怎么会呢 应该是打招呼有问题 问就说实习6个月全国可飞随时到岗
点赞 评论 收藏
分享
酷酷我灵儿帅:这去不去和线不线下面说实话没啥关系
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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