leetcode-889-Construct Binary Tree from Preorder and Postorder Traversal

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zem_nezer/article/details/86619919

Get the pattern from it, 1) We know that in pre-order: [root, left, right], in post-order: [left, right, root] 2) so that root + 1 in pre-order must be the root of left subtree, root - 1 in post-order must be the root of right subtree. 3) call a function(pre_root, post_root, size), which get the root of pre and post array, and the size of the function. In the function, find the root of left and right subtree.

Error:
N/A

猜你喜欢

转载自blog.csdn.net/zem_nezer/article/details/86619919
今日推荐