construct-binary-search-tree-from-preorder-traversal
Problem
Construct Binary Search Tree from Preorder Traversal
Problem Description
Solution
Binary Search Tree, left.val < root.val < right.val
preorder (root -> left -> right) means the first is root value, recursively traverse array:
if smaller than root value, left tree
if bigger than root value, right tree
For example:
Complexity Analysis
Time Complexity: O(N)
N - the length of array nums
Code
Last updated