Matrix-Tree 定理作用:给定 n 个点 m 条边的无向图,求图的生成树个数。 定义矩阵K[i][j]=D[i][j]-A[i][j],(其中D为度数矩阵(即当i==j时,D[i][j]=节点 i 的度数,其余为0),A为邻接矩阵,有边相邻即为1,其余为0) 结论:对于已经得出的基尔霍夫矩阵 ...
分类:
其他好文 时间:
2020-05-08 13:10:58
阅读次数:
132
题目大意:一棵树,然后m个询问,每个询问有k个点,然后判断是否有一条路,要求这k个点要么在这条路上,要么和这条路相距为1. 题解:刚开始的思路是这样的,这条路的终点肯定是深度最深的那个点,然后用BFS找到从1到终点的路线,然后在对路径上的点和与路径直接相连的点进行判断,看这k个点是否都在其中,然后就 ...
分类:
其他好文 时间:
2020-05-08 13:06:29
阅读次数:
53
In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. Two nodes of a binary tree are cousins if they have ...
分类:
其他好文 时间:
2020-05-08 12:40:20
阅读次数:
59
为了达到较高的执行效率,lua代码并不是直接被Lua解释器解释执行,而是会先编译为字节码,然后再交给lua虚拟机去执行 lua代码称为chunk,编译成的字节码则称为二进制chunk(Binary chunk) lua.exe、wlua.exe解释器可直接执行lua代码(解释器内部会先将其编译成字节 ...
分类:
其他好文 时间:
2020-05-08 00:28:31
阅读次数:
72
Given a non-empty tree with root R, and with weight W?i?? assigned to each tree node T?i??. The weight of a path from R to L is defined to be the sum ...
分类:
其他好文 时间:
2020-05-07 23:06:39
阅读次数:
102
https://leetcode-cn.com/problems/subtree-of-another-tree/ 我们需要借助一个helper方法,这个思想就是双递归,即判断每个大树的节点和小树的根节点的值是否相等,如果相同就进入子树判断方法。否则就在大树节点的左节点和右节点查找。 helper方 ...
分类:
其他好文 时间:
2020-05-07 13:50:01
阅读次数:
58
https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/solution/li-jie-zhe-dao-ti-de-jie-shu-tiao-jian-by-user7208/ 思路:有个特殊情况,比如树是1,2.这样的话,根节点为 ...
分类:
其他好文 时间:
2020-05-07 10:48:03
阅读次数:
60
Python virtual env 最近在用ops写的一个脚本,需要用到python 3,以及部分安装依赖,于是顺利的安装了python 3的环境,但是一切并没有那么的顺利,依赖的一个包死活无法安装,于是了解到了python的 "虚拟环境" . 使用 命令行输出 可以看到文件中多了一个v env的 ...
分类:
编程语言 时间:
2020-05-06 15:35:47
阅读次数:
90
Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and ino ...
分类:
其他好文 时间:
2020-05-06 13:56:18
阅读次数:
55
题目描述 给定一个二叉搜索树,编写一个函数?kthSmallest?来查找其中第?k?个最小的元素。 说明: 你可以假设 k 总是有效的,1 ≤ k ≤ 二叉搜索树元素个数。 示例: 题目链接: https://leetcode cn.com/problems/kth smallest elemen ...
分类:
其他好文 时间:
2020-05-06 12:02:09
阅读次数:
46