二叉搜索树(1)定义二叉搜索树(Binary Search Tree),也称二叉排序树或二叉查找树一棵二叉树,可以为空;如果不为空,满足以下性质:a.非空左子树的所有键值小于其根节点的键值b.非空右子树的所有键值大于其根节点的键值c.左右子树都是二叉搜索树(2)相关操作Position Find( ...
分类:
其他好文 时间:
2015-01-14 00:44:20
阅读次数:
210
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep...
分类:
其他好文 时间:
2015-01-14 00:43:38
阅读次数:
166
#include "iostream"
#include "memory.h"
using namespace std;
/*
找根方法:
每个节点输入次数:根节点在输入自己时输入一次,
非根节点在输入父节点时输入一次,在输入自己时又输入
一次,所以输入了两次。所以可以通过计数器,计算每个节点
被输入的次数来找出根节点。
*/
const int MAX = 1002;...
分类:
其他好文 时间:
2015-01-13 21:37:09
阅读次数:
180
此错误比较难定位,场景是这样的:在一个widget中使用了自定义控件,始终会报android.view.InflateException:BinaryXMLfileline#2:Errorinflatingclass...这个错误。最后实在没有办法了,写了一个demo中只有一个重写的textview...
分类:
移动开发 时间:
2015-01-13 21:30:42
阅读次数:
172
这题很难,主要是我没理解题目的意思,后来看着给的测试参考,和网上找的答案,终于理解了。 例如: 给的 正确的路线应该是 也就是说,路径是一条的,不是有分叉的,之所以算出55是因为把>0的数都加上去了,这样路径就分叉了,就不是一条路径了,所以用dfs做时,返回值应该是左子树或者右子树中>0且比较大的那...
分类:
其他好文 时间:
2015-01-13 21:17:50
阅读次数:
127
https://oj.leetcode.com/problems/unique-binary-search-trees/Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For...
分类:
其他好文 时间:
2015-01-13 21:13:32
阅读次数:
161
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example: Given the below binary tree and sum...
分类:
其他好文 时间:
2015-01-13 19:55:05
阅读次数:
174
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solutio...
分类:
其他好文 时间:
2015-01-13 19:51:27
阅读次数:
142
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 1
\ ...
分类:
其他好文 时间:
2015-01-13 19:50:02
阅读次数:
147
问题描述:
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Given ...
分类:
其他好文 时间:
2015-01-13 19:49:51
阅读次数:
152