Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-04-23 23:19:15
阅读次数:
147
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great":
great
/ gr ...
分类:
其他好文 时间:
2015-04-23 17:40:47
阅读次数:
205
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-04-23 17:35:14
阅读次数:
145
判断一棵树是否是平衡树。平衡数的意思是,树左右子树高度之差不能超过1.【思路】递归判断每个子树是否是平衡数,需要调用高度计算的函数。【my code】bool isBalanced(TreeNode *root) { if(root==NULL) return t...
分类:
其他好文 时间:
2015-04-23 17:17:21
阅读次数:
181
problem:
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 which the depth of the two subtrees of ev...
分类:
其他好文 时间:
2015-04-23 15:47:04
阅读次数:
166
题目来自:LeetCode
https://leetcode.com/problems/populating-next-right-pointers-in-each-node/
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
...
分类:
其他好文 时间:
2015-04-23 13:22:50
阅读次数:
143
Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in th...
分类:
其他好文 时间:
2015-04-23 13:16:06
阅读次数:
124
problem:
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree...
分类:
其他好文 时间:
2015-04-23 11:02:24
阅读次数:
163
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming
weight).
For example, the 32-bit integer ’11' has binary representation 000000...
分类:
其他好文 时间:
2015-04-23 10:59:45
阅读次数:
206
problem:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
Hide Tags
Tree Depth-first
Search
题意:将一个递增的序列 转换成一棵 平衡查找二叉树
...
分类:
其他好文 时间:
2015-04-23 10:59:34
阅读次数:
201