LeetCode解题心得——反转链表(python)
题目 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 思路 1.递归 class Solution: def reverseList(self, head: ListNode) -> ListNode: if head == None or head.next == None: return head next = head.next new_head = self.reverseList(next) next.next =