Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 3
But the f...
分类:
其他好文 时间:
2015-01-14 11:08:56
阅读次数:
154
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 20
...
分类:
其他好文 时间:
2015-01-14 11:08:38
阅读次数:
226
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n)
space is pretty straight forward. Could you devis...
分类:
其他好文 时间:
2015-01-14 09:53:16
阅读次数:
154
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.Th...
分类:
其他好文 时间:
2015-01-14 09:52:48
阅读次数:
161
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 ...
分类:
其他好文 时间:
2015-01-14 09:52:27
阅读次数:
150
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
/**
* Defin...
分类:
其他好文 时间:
2015-01-14 09:48:40
阅读次数:
139
二叉搜索树(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