题解 | #反转链表# js

反转链表

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

var reverseList = function(head) {
    if(head === null) return null
    let p = null, m = head, n = head.next
    while(m !== null){
        console.log(m.val)
        m.next = p
        p = m
        m = n 
        if(n !== null)n = n.next
    }
    return p
};


全部评论

相关推荐

27双非本,最近面试被挂麻了面试官说简历内容太简单了,技术栈要单独一行,各位佬有啥建议吗
LZStarV:项目太简单了,你像用什么开发的技术栈没必要写一句话,按点写就好了;有特色的比如说WebSocket、视频流这种狠狠吹,那就好看多了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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