# 反转链表

var reverseList = function (head) {
  // 迭代
  const pre = null
  const current = head
  while (current) {
    const next = current.next
    // 反转链表
    current.next = pre
    // 移动指针
    pre = current
    current = next
  }
  return pre
}

var reverseList = function (head) {
  // 递归
  if (head === null || head.next === null) {
    return head
  }
  const last = reverseList(head.next)
  head.next.next = head
  head.next = null
  return last
}