Reverse a Linked List
Given the head of a singly linked list, reverse the list and return the new head.
Examples
in: head = [1,2,3,4,5]
out: [5,4,3,2,1]
order reversed
in: head = []
out: []
empty stays empty
Constraints
- 0 <= number of nodes <= 10^4
- -10^9 <= node value <= 10^9
Hints