class Solution:
def reverseList(self, head):
#iteration
if not head:
return head
pre = None
while head:
nxt = head.next
head.next = pre # 转向
# move
pre = head
head = nxt
return pre
#recursion
if not head or not head.next:
return head
new_head = self.reverseList(head.next)
head.next.next = head # 转向
head.next = None
return new_head