# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reorderList(self, head: Optional[ListNode]) -> None:
"""
Do not return anything, modify head in-place instead.
"""
tmp = []
cur = head
while cur:
tmp.append(cur)
cur = cur.next
l, r = 0, len(tmp) - 1
while l < r: # 退出循环时 l == r
tmp[l].next = tmp[r]
l += 1
if l == r: break # 易错点
tmp[r].next = tmp[l]
r -= 1
# 退出循环时 l 刚好指在中间节点(奇数时), 或中间位置的下一个节点(偶数时)
tmp[l].next = None # 易错点