Reverse a Linked List
Given the head of a linked list, reverse the linked list and return the new head.
const reverseList = function(head) {
// Enter your logic here...
}
Examples:
Input: [1,2,3]
Output: [3,2,1]
Explanation: Node 3 is now the new head.
Input: [1]
Output: [1]
Explanation: There is only one node in the list.