Reverse a linked list
Asked in the Technical Interview 1 stage. Easy DSA.
Implement reverse_linked_list(head) for a singly linked list. Each node has val and next fields. Return the new head after reversing the links in place. Test cases represent linked lists as arrays of node values, with the expected result also represented as an array.
def reverse_linked_list(head):