Skip to content

206反转链表

code

javascript
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function(head) {
    
    let newHead;
     1 -> 2 
     head = 1
     head.next = 2;
     head.next.next = head;
     head.next = null;
     newHead = reverseList(head.next)
    return newHead;
    
};

总结