 All Problems
Verify Preorder Sequence in Binary Search Tree
medium
trees
stack
binary search tree
amazon
microsoft

Given a list of unique integers as a preorder traversal sequence, determine if it represents a valid BST preorder traversal.

Example 1:

Input: 5 2 1 3 6
Output: true

Example 2:

Input: 5 2 6 1 3
Output: false

Input format: Space-separated integers.

Output format: true or false.

Run to check your code against the sample cases, or submit to run every case