码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
538-把二叉搜索树转换为累加树
538 把二叉搜索树转换为累加树 给定一个二叉搜索树(Binary Search Tree),把它转换成为累加树(Greater Tree),使得每个节点的值是原来的节点值加上所有大于它的节点值之和。 例如: 来源:力扣(LeetCode) 链接:https://leetcode cn.com/pr ...
分类:其他好文   时间:2020-01-27 20:38:35    阅读次数:74
LeetCode 173. Binary Search Tree Iterator(搜索二叉树)
"题目" 题意:实现一个BST的Next()函数,输出BST里的从小到大的数字。 题解:题目说Next()的时间效率O(1),空间效率O(h),h为树的高度。我们维护一个栈,把前序遍历的左子树的结果存进去。 每次Next取出栈顶元素的时候,再遍历栈顶元素的右子树的前序遍历的左子树部分。 ...
分类:其他好文   时间:2020-01-27 17:34:01    阅读次数:58
@atcoder - AGC018F@ Two Trees
给定两棵树 A, B。现你需要构造一组值 (X1, X2, ..., XN)(两棵树编号相同的点对应权值相同),使得两棵树内任意子树的权值和的绝对值为 1。 无解输出 IMPOSSIBLE。 ...
分类:其他好文   时间:2020-01-26 19:09:34    阅读次数:102
PAT Advanced 1102 Invert a Binary Tree (25分)
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a ...
分类:其他好文   时间:2020-01-26 19:05:54    阅读次数:58
PAT Advanced 1099 Build A Binary Search Tree (30分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes ...
分类:其他好文   时间:2020-01-26 16:10:12    阅读次数:98
PAT Advanced 1064 Complete Binary Search Tree (30分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes ...
分类:其他好文   时间:2020-01-26 14:40:36    阅读次数:61
二叉树遍历 A1102. Invert a Binary Tree (25) 反转二叉树 并输出层序和中序遍历 (使用静态二叉树)
#include <bits/stdc++.h> #include <stdio.h> #include <stdlib.h> #include <queue> using namespace std; const int maxn = 110; struct node{ int lchild,rc ...
分类:其他好文   时间:2020-01-24 17:25:43    阅读次数:78
c++设计模式-原型模式
动机 在软件系统中,经常面临着“某些结构复杂的对象”的创建工作;由于需求的变化,这些对象经常面临着剧烈的变化,但是他们却拥有比较稳定一致的接口。 如何应对这种变化?如何向“客户程序(使用这些对象的程序)”隔离出“这些易变对象”,从而使得“依赖这些易变对象的客户程序”不随着需求改变而改变? 模式定义 ...
分类:编程语言   时间:2020-01-23 15:32:23    阅读次数:79
513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3 / / \ 4 5 ...
分类:其他好文   时间:2020-01-23 11:15:55    阅读次数:75
515. Find Largest Value in Each Tree Row
You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] class Solution { public List< ...
分类:其他好文   时间:2020-01-23 11:01:57    阅读次数:57
共12390条   上一页 1 ... 87 88 89 90 91 ... 1239 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!