Given a singly linked list. Write a function
ListNode ReverseLinkedList(ListNode head) that reverses the list and returns the new head.Example 1
Input: head = [1,2]
Output: [2,1]
Explanation:
Output: [2,1]
Explanation:
Example 2
Input: head = []
Output: []
Explanation:
Output: []
Explanation:
Example 3
Input: head = [1,2,3,4,5]
Output: [5,4,3,2,1]
Explanation:
Output: [5,4,3,2,1]
Explanation: