Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 282 Bytes

File metadata and controls

12 lines (10 loc) · 282 Bytes

This problem was asked by Google.

Given the sequence of keys visited by a postorder traversal of a binary search tree, reconstruct the tree.

For example, given the sequence 2, 4, 3, 8, 7, 5, you should construct the following tree:

    5
   / \
  3   7
 / \   \
2   4   8