码迷,mamicode.com
首页 >  
搜索关键字:binary tree upside d    ( 23249个结果)
100. 相同的树
<两棵树的操作技巧> 题目 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] 输出: true 示例 2: 输入: 1 1 / \ 2 2 ...
分类:其他好文   时间:2019-08-18 23:38:22    阅读次数:125
98-Validate Binary Search Tree
题目:验证一个二叉树是否为二叉排序树 注: 采用遍历二叉树的中序遍历,如果结果为排序,则说明该二叉树是二叉排序树 ...
分类:其他好文   时间:2019-08-18 17:49:52    阅读次数:76
Magic boy Bi Luo with his excited tree (树形dp)
Bi Luo is a magic boy, he also has a migic tree, the tree has NN nodes , in each node , there is a treasure, it's value is V[i]V[i], and for each edge ...
分类:其他好文   时间:2019-08-18 14:00:56    阅读次数:73
leetcode1161
算法思路:二叉树层次遍历 ...
分类:其他好文   时间:2019-08-18 13:44:23    阅读次数:78
Binary Transformations (贪心)Gym 101669F
分析:比较容易想到的是用两个容器分别存放需要'1'变为'0'的值以及需要'0'变为'1'的值,1->0需要从大到小排序,0->1的需要从小到大排序进行贪心选择 但是如果存在这样的位置(变化前后都为1),我们就要枚举一开始把哪些这样的位置进行转换,显然是价值越大的越优先转换,因为这样代价小。 ...
分类:其他好文   时间:2019-08-18 12:10:11    阅读次数:73
[SGU 155] Cartesian Tree
笛卡尔树模板题,但是蒟蒻调这道题比调它的变式题目调的更久,我果然是菜过头了 "原题传送门" include define ll long long using namespace std; const int maxn = 50000 + 10; int n, top; int fa[maxn], ...
分类:其他好文   时间:2019-08-18 12:00:41    阅读次数:87
leetcode 230. Kth Smallest Element in a BST
中序遍历,计数器数到k时,输出当前节点值 ...
分类:其他好文   时间:2019-08-18 11:35:11    阅读次数:65
leetcode 173. Binary Search Tree Iterator
class BSTIterator { private Stack stack; public BSTIterator(TreeNode root) { stack = new Stack(); while(root != null){ stack.push(root); root = root..... ...
分类:其他好文   时间:2019-08-18 10:14:16    阅读次数:90
Balanced Binary Tree
Question Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in whic ...
分类:其他好文   时间:2019-08-18 09:59:24    阅读次数:100
leetcode 109. Convert Sorted List to Binary Search Tree
其实就是一个二分搜索 首先遍历LinkedList,记下链表长度 然后从mid开始, mid.left = 左部的mid mid.right = 右部的mid 依次递归,因为这相当于一个中序遍历,调用栈的最底层是从LinkedList首个元素开始的 ...
分类:其他好文   时间:2019-08-18 09:17:40    阅读次数:74
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!