> For the complete documentation index, see [llms.txt](https://llssff.gitbook.io/coding-problems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://llssff.gitbook.io/coding-problems/linkedlist/reverse.md).

# Reverse

Reverse a linked list given the head

```
public ListNode Reverse(ListNode root){
    if (root == null || root.next == null) return root;
    
    ListNode newHead = Reverse(root.next);
    root.next.next = root;
    root.next = null;
    
    return newHead;
}
```

TC: O(N)

SC: O(1)
