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

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.