case1:
if not head or not head.next:
return head
slow = head
fast = head
# 用快慢指针分成两部分
while fast.next and fast.next.next:
slow = slow.next
fast = fast.next.next
case2
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next