摘要: 求出这棵树的直径,即两个节点距离的最大值。 思路:求最大与次大 import collections class Solution: ans=0 def solve(self , n , es, ev): g=collections.defaultdict(list) for e,v in zip( 阅读全文
posted @ 2020-11-29 16:31 童年の波鞋 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 设 t1 树的边集为 E1,t2 树的边集为 E2,若 E2 等于 E1 ,则表示 t1 树和t2 树的拓扑结构完全相同。 思路: 双指针判断子序列的思想 public class Solution { public boolean isContains (TreeNode p, TreeNode 阅读全文
posted @ 2020-11-29 15:37 童年の波鞋 阅读(214) 评论(0) 推荐(0) 编辑