摘要:
BFS模板的应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html class Solution(object): def levelOrder(self, root): """ :type root: TreeNod 阅读全文
posted @ 2020-09-13 16:07
人间烟火地三鲜
阅读(76)
评论(0)
推荐(0)
摘要:
class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root: return True return self.helper(root.left, 阅读全文
posted @ 2020-09-13 16:05
人间烟火地三鲜
阅读(97)
评论(0)
推荐(0)
摘要:
class Solution(object): def isCousins(self, root, x, y): """ :type root: TreeNode :type x: int :type y: int :rtype: bool """ # 用字典记录每个节点的父节点、以及该节点的深度( 阅读全文
posted @ 2020-09-13 16:01
人间烟火地三鲜
阅读(120)
评论(0)
推荐(0)
摘要:
DFS应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html class Solution(object): def increasingBST(self, root): """ :type root: TreeNod 阅读全文
posted @ 2020-09-13 15:57
人间烟火地三鲜
阅读(130)
评论(0)
推荐(0)
摘要:
class Solution(object): def leafSimilar(self, root1, root2): """ :type root1: TreeNode :type root2: TreeNode :rtype: bool """ res1 = [] self.dfs(root1 阅读全文
posted @ 2020-09-13 15:54
人间烟火地三鲜
阅读(129)
评论(0)
推荐(0)
摘要:
BFS模板的应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html 注:"/"符号两边只要有一个float类型,结果自动取float类型!!! class Solution(object): def averageOf 阅读全文
posted @ 2020-09-13 15:51
人间烟火地三鲜
阅读(127)
评论(0)
推荐(0)
摘要:
方法一:递归。 class Solution(object): # 递归 def mergeTrees(self, t1, t2): """ :type t1: TreeNode :type t2: TreeNode :rtype: TreeNode """ if not t1 and not t2 阅读全文
posted @ 2020-09-13 15:47
人间烟火地三鲜
阅读(170)
评论(0)
推荐(0)
摘要:
方法一:BFS模板的应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html class Solution(object): def maxDepth(self, root): """ :type root: Node 阅读全文
posted @ 2020-09-13 15:43
人间烟火地三鲜
阅读(151)
评论(0)
推荐(0)
摘要:
BFS模板的应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html class Solution(object): def largestValues(self, root): """ :type root: Tree 阅读全文
posted @ 2020-09-13 15:39
人间烟火地三鲜
阅读(154)
评论(0)
推荐(0)
摘要:
方法一:BFS模板的应用。 总结的DFS、BFS模板参考:https://www.cnblogs.com/panweiwei/p/13065661.html class Solution(object): # BFS def findBottomLeftValue(self, root): """ 阅读全文
posted @ 2020-09-13 15:36
人间烟火地三鲜
阅读(205)
评论(0)
推荐(0)

浙公网安备 33010602011771号