面试题1:反转链表

45 阅读1分钟

leetcode 链接

var reverseList = function(head) {
    let current = head
    let newListNode = null
    while (current) {
        let next = current.next
        current.next = newListNode
        newListNode = current
        current = next
    }
    return newListNode
};