> For the complete documentation index, see [llms.txt](https://emmaguo100.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emmaguo100.gitbook.io/leetcode/01-12-2022-206.md).

# 01/12/2022 206

method 1: interative

traverse the linkedlist and change the current node.next to the previous node. So we need a pointer to store its previuous node. We also need another pointer to store the next node before changing the reference.&#x20;

Time O(N)

Space O(1)

![](/files/nolTxfKOuFYwofoPsPq1)

method 2

recursion

recursively call the p = reverseList(head.next). Then set the head.next.next = head and head.next = null

Time O(n)

Space O(n)

![](/files/LlYZQK8NxZPM1vOngXb5)
