当前位置 : 主页 > 手机开发 > harmonyos >

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

来源:互联网 收集:自由互联 发布时间:2023-08-26
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) c


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


【转自:大丰网站建设 http://www.1234xp.com/dafeng.html 欢迎留下您的宝贵建议】
上一篇:leetcode-141-Linked List Cycle
下一篇:没有了
网友评论