Sunday, March 10, 2019

1008. Construct Binary Search Tree from Preorder Traversal

March 10, 2019

Introduction


It is a medium level algorithm. I spent 52 minutes to solve the problem. I need to look into the issue how to expedite my problem solving.

Think about all possible options


What I do is to find left child subarray start and end position, same as right child's start and end position.

What I calculate in the contest is the last index of left child subarray.

Here is the another idea to calculate the last index of left child. I saw the discussion link.



Hack a solution

No comments:

Post a Comment