Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all ... ...
分类:
其他好文 时间:
2017-07-09 23:58:24
阅读次数:
466
传送门 Description Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new rev ...
分类:
其他好文 时间:
2017-07-09 23:56:18
阅读次数:
243
转自:http://www.cnblogs.com/yangecnu/p/Introduce-2-3-Search-Tree.html 前面介绍了二叉查找树(Binary Search Tree),他对于大多数情况下的查找和插入在效率上来说是没有问题的,但是他在最差的情况下效率比较低。本文及后面文章 ...
分类:
其他好文 时间:
2017-07-09 22:07:52
阅读次数:
273
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7 Output... ...
分类:
其他好文 时间:
2017-07-09 19:46:58
阅读次数:
137
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/#/description Given a binary tree, find the lowest common ancestor (LCA) of two ...
分类:
其他好文 时间:
2017-07-09 16:18:14
阅读次数:
179
1. 问题描述: 旋转一颗二叉树(每一个节点的左右子数都要交换) 2. 解答: 这题没看答案之前我是用后序遍历(先左后右最后中)去做的,很奇怪自己为什么没有一开始就想到更符合直觉的先序遍历~~~ 本人算法的伪代码 : function invert (root) if root为空 then end ...
分类:
其他好文 时间:
2017-07-09 14:50:20
阅读次数:
212
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 思路: 层次遍历。 ...
分类:
其他好文 时间:
2017-07-09 13:57:22
阅读次数:
195
题目: 链接 解答: 自底向上求解。left_max right_max分别返回了左右子树的最大路径和,假设左右子树最大路径和小于0。那么返回零。 用这个最大路径和和根节点的值相加。来更新最大值,同一时候。 更新返回该树的最大路径值。 代码: class Solution { public: int ...
分类:
其他好文 时间:
2017-07-09 12:28:09
阅读次数:
129
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. /** * Definition for binary tree * struct TreeNode { ...
分类:
其他好文 时间:
2017-07-09 10:26:57
阅读次数:
153
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n ...
分类:
其他好文 时间:
2017-07-08 21:06:52
阅读次数:
119