Given the head of a singly linked list, reverse the list, and return the reversed list. Input/output is given as an array representation of the linked list.
Example 1
Input: head = [1,2,3,4,5]
Output: [5,4,3,2,1]
Explanation: Pointing every node back at the one before it turns 1 → 2 → 3 → 4 → 5 into 5 → 4 → 3 → 2 → 1.
Example 2
Input: head = [1,2]
Output: [2,1]
Explanation: The two nodes swap order: 2 → 1.
Example 3
Input: head = []
Output: []
Explanation: An empty list reversed is still empty.
Trust recursion: "reverse the tail" gives back the new head of an already-reversed sub-list. All we have to do at this level is hook the current node onto the *end* of that reversed tail.
Run checks all cases above. Submit evaluates all test cases.