MCPcopy Create free account
hub / github.com/algorithm004-03/algorithm004-03 / buildTree

Method buildTree

Week 02/id_498/LeetCode_105_498.py:13–31  ·  view source on GitHub ↗

因为前序遍历 第一位就是总根元素,又因为没有重复的数值,所以从中序里找到根节点 种根 根节点的索引还代表,左子树有多少个节点, 然后构造左右子树

(self, preorder: List[int], inorder: List[int])

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

Calls 1

TreeNodeClass · 0.70

Tested by

no test coverage detected