反转一个单链表。

示例:

输入1:

1->2->3->4->5->None 

输出1:

5->4->3->2->1->None

解答:

def reverseList(self, head: ListNode) -> ListNode:
    if head is None or head.next is None: return head
    result = self.reverseList(head.next)
    head.next.next = head
    head.next = None
    return result