35. Reverse Linked List

Reverse a singly linked list and return the new head.

Example 1

Input: head = [1,2,3,4]
Output: [4,3,2,1]

Example 2

Input: head = [7,8]
Output: [8,7]
Hint 1

You need three pointers: prev, curr and next.

Linked List