码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
LeetCode 669. Trim a Binary Search Tree
二叉查找树的套路一般都是 先根据 root->val 和一些条件缩小范围。 本题中,如果 根节点小于L,递归右子树,如果大于R,递归左子树。如果在两者之间,表明root一定是符合要求的,递归左子树和右子树,并和root接起来。 时间复杂度 O(n),最多访问每个节点一次。 空间复杂度 O(h) 递归 ...
分类:其他好文   时间:2018-08-25 11:35:43    阅读次数:137
LeetCode 96. Unique Binary Search Trees
这道题和树基本没什么关系,完全就是 Catalan Number。 给定一个数 i , 1作为根,左边有 0 个节点,右边有 i-1 个节点 2作为根,左边有 1 个节点,右边有 i-2 个节点 ... i 作为根,左边有 i-1 个节点,右边有 0 个节点 记 dp[i] 为给定 i 时的个数,d ...
分类:其他好文   时间:2018-08-25 11:29:40    阅读次数:123
Exam 4894 Booming Business
4894: Booming Business 题目描述 You are an expert in bonsai, the Japanese art of cultivating small trees in small containers.Every year, you win the Bonsa ...
分类:其他好文   时间:2018-08-24 22:58:12    阅读次数:202
【PAT】1020 Tree Traversals (25)(25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:其他好文   时间:2018-08-24 21:46:35    阅读次数:197
[动态规划]Booming Business
题目描述 You are an expert in bonsai, the Japanese art of cultivating small trees in small containers.Every year, you win the Bonsai Association’s Pruning ...
分类:其他好文   时间:2018-08-24 20:42:50    阅读次数:201
67. 二进制求和
67. 二进制求和 https://leetcode-cn.com/problems/add-binary/description/ char 转int char-'0' ...
分类:其他好文   时间:2018-08-24 19:20:33    阅读次数:100
1135 Is It A Red-Black Tree
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties: (1) Every node is either ...
分类:其他好文   时间:2018-08-24 17:19:54    阅读次数:144
Visible Trees HDU - 2841(容斥)
对于已经满足条件的(x1,y1),不满足条件的点就是(n*x1,n*y1),所以要求的就是满足点(x,y)的x,y互质,也就是gcd(x,y) == 1,然后就可以用之前多校的方法来做了 另f[i] 表示gcd为 i 的倍数的对数 g[i] 表示gcd == i 的对数 f[i] = (n/i) * ...
分类:其他好文   时间:2018-08-24 17:18:16    阅读次数:110
Linux系统上传下载命令rz和sz
Linux系统简单易用的上传下载命令rz和szyuminstalllrzsz-y上传(rz)-b,--binary:以二进制方式传输,推荐使用-e,--escape:对所有控制字符转义,建议使用-y,--overwrite:存在同名文件则替换以二进制,并对控制字符进行转义,替换已存在的同名文件rz-bye下载(sz)可以下载多个文件szfile1file2file3
分类:Web程序   时间:2018-08-24 16:08:48    阅读次数:265
【Codeforces】CF 9 D How many trees?(dp)
题目 分析 用$ dp[i][j] $表示用i个节点,有多少深度小于等于j的二叉树。 答案是$ dp[n][n] - dp[n][h-1] $ 转移时枚举左子树的节点数量,就可以知道右子树的节点数量。不断相乘加到$ dp[i][j] $上。 代码 1 #include <bits/stdc++.h> ...
分类:其他好文   时间:2018-08-24 02:02:20    阅读次数:144
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!