摘要:
题目如下: 本题目的思路基本和105题的思路是相同的,主要要注意进行divide和conqure的时候,index的下标要调整正确,记住python是左闭右开的。 代码如下: # Definition for a binary tree node. # class TreeNode: # def _ 阅读全文
摘要:
这题目是有一个常见的套路的,由于先序遍历的结果list都会遵循这样的一个排列方式,也就是第一个是root,后面的分别是左子树的node的集合,以及右子树的node的集合。 [ 根节点, [左子树的前序遍历结果], [右子树的前序遍历结果] ] 而inorder中序遍历的结果则是: [ [左子树的中序 阅读全文