Problem 1008 · Medium

Construct Binary Search Tree from Preorder Traversal

Each preorder value is placed inside the bounds left by its ancestors, so one pass with an index builds the whole tree.

Open the interactive visualisation