255. Verify Preorder Sequence in Binary Search Tree

Problem

Given a sequence of numbers, verify it is a valid preorder traversal of a binary search tree.

Given an array preorder representing the preorder traversal of a BST (without duplicates), determine if it is a valid preorder sequence.

In preorder, we visit: node, then left subtree, then right subtree.

Examples
Input: [5,2,6,1,3]
Output: false
Hints
Related Problems

255. Verify Preorder Sequence in Binary Search Tree

Given a sequence of numbers, verify it is a valid preorder traversal of a binary search tree.