13. Reverse a Linked List
EasyLinked lists
Reverse a singly linked list and return the new head.
A linked list is passed as ListNode objects with val and next. The tests write lists as arrays.
Example 1
Input: head = [1, 2, 3, 4, 5] Output: [5, 4, 3, 2, 1]
Constraints
0 ≤ nodes ≤ 5000