写出一坨大便
对不起对不起对不起
早上拉屎应该很正常吧:(
def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:
    first_idx, last_idx,idx = 10**6,-1,0
    mindis = 10**6
    pre_idx = -1
    pre_val = -1
    while head is not None:
        if pre_val != -1 and head.next is not None:
            if (pre_val<head.val and head.next.val<head.val) or
(pre_val>head.val and head.next.val>head.val):
                first_idx = min(first_idx, idx)
                last_idx = max(last_idx, idx)
                mindis = 10**6 if pre_idx == -1 else min(idx-pre_idx, mindis)
                pre_idx = idx
        pre_val = head.val
        head = head.next
        idx += 1
    return [-1 if mindis == 10**6 else mindis, -1 if first_idx==10**6 and
last_idx==-1 or first_idx==last_idx else last_idx-first_idx]