遍历链表,将每个节点的next指向新链表的头,然后该节点成为新链表头
let reverseList = function(head) {// 遍历链表,将每个节点的next指向新链表的头,然后该节点成为新链表头let newListHead = null;while (head != null) {let tmp = head.next;head.next = newListHead;newListHead = head;head = tmp;}return newListHead;};
