Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to rebuild the python binary tree, find out the maximum value of the gift, and calculate 1 binary 2 +. + n

Shulou Source: shulou.com Published: 2022-06-01 14:11:46 10月24日 Update

How to rebuild the python binary tree, find out the maximum value of the gift, and calculate 1 binary 2 +. + n, aiming at this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Enter the results of preorder traversal and mid-order traversal of a binary tree, please rebuild the binary tree. Assume that the results of both the preorder traversal and the intermediate traversal of the input do not contain duplicate numbers.

For example, give the

Preorder traversal preorder = [3pm 9pm 20je 15rem 7]

Traversing in the middle order inorder = [9 ~ 1 ~ 3 ~ 15 ~ 20 ~ 7]

Return the following binary tree:

three

/\

9 20

/\

15 7

Restrictions:

0

Tags: Gift value input chessboard subtree maximum same code idea example node problem output limit find three two location element that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux vpn macOS Microsoft