parameters: (self, head)
return_statement: return [result, last-first] if last != first else [-1, -1]
docstring: :type head: Optional[ListNode]
          :rtype: List[int]
docstring_summary: :type head: Optional[ListNode]
          :rtype: List[int]
docstring_tokens: : type head : Optional [ ListNode ] : rtype : List [ int ]
function: def nodesBetweenCriticalPoints(self, head):
          """
          :type head: Optional[ListNode]
          :rtype: List[int]
          """
          first = last = -1
          result = float("inf")
          i, prev, head = 0, head.val, head.next
          while head.next:
              if max(prev, head.next.val) < head.val or min(prev, head.next.val) > head.val:
                  if first == -1:
                      first = i
                  if last != -1:
                      result = min(result, i-last)
                  last = i
              i += 1
              prev = head.val
              head = head.next
          return [result, last-first] if last != first else [-1, -1]
function_tokens: def nodesBetweenCriticalPoints ( self , head ) : first = last = - 1 result = float ( "inf" ) i , prev , head = 0 , head . val , head . next while head . next : if max ( prev , head . next . val ) < head . val or min ( prev , head . next . val ) > head . val : if first == - 1 : first = i if last != - 1 : result = min ( result , i - last ) last = i i += 1 prev = head . val head = head . next return [ result , last - first ] if last != first else [ - 1 , - 1 ]