Skip to content

反转链表

🕒 Published at:

LeetCode 第206题

js
var reverseList = function (head) {
  if (head == null) return null
  if (head.next == null) return head
  let res = reverseList(head.next)
  head.next.next = head
  head.next = null
  return res
};