问题描述:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
基本思想:
二分法构建二差排序树。
代码:
TreeNode *subsortedArrayToBST(vector & num,int begin, int end) /...
分类:
其他好文 时间:
2014-12-04 23:18:01
阅读次数:
189
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the total sum ...
分类:
其他好文 时间:
2014-12-04 21:39:20
阅读次数:
209
题意:
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....
分类:
其他好文 时间:
2014-12-04 21:38:52
阅读次数:
244
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2014-12-04 21:29:50
阅读次数:
104
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...
分类:
其他好文 时间:
2014-12-04 21:25:46
阅读次数:
139
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2014-12-04 21:21:05
阅读次数:
153
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
简单的思想:正序排列时,某节点的右节点一定是该节点的右子树,中序排列,某节点的左节点一定是该节点的左子树;
...
分类:
其他好文 时间:
2014-12-04 18:03:12
阅读次数:
143
/**
?*?@brief?Codeforces?Round?#280?(Div.?2)?d
?*?@file?d.cpp
?*?@author?mianma
?*?@created?2014/12/02?14:38
?*?@edited??2014/12/02?14:38
?*?@type?math?brute?binary_sear...
分类:
其他好文 时间:
2014-12-04 14:08:32
阅读次数:
193
Reference:http://blog.csdn.net/v_july_v/article/details/18312089 http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-ii.html(1) ....
分类:
其他好文 时间:
2014-12-04 08:48:25
阅读次数:
200
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the sequence of...
分类:
其他好文 时间:
2014-12-04 08:47:00
阅读次数:
168