Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree...
分类:
其他好文 时间:
2015-10-26 00:02:41
阅读次数:
155
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.讲一个排序好的数组转换成二叉搜索树,这题没想出来,基本上是参考别人的,边界条件应该注意一下: 1 /** ...
分类:
编程语言 时间:
2015-10-25 22:27:01
阅读次数:
272
二分搜索(binary search):给定一个整数X和整数A1,A1,...,AN-1,后者已经预先排序并在内存中,求下标 i 使得 Ai = X,如果X不在数据中,则返回-1。 1 #include 2 #include 3 using namespace std; 4 5 const...
分类:
编程语言 时间:
2015-10-25 22:15:21
阅读次数:
268
题目:Maximal SquareGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.样例For example, given...
分类:
其他好文 时间:
2015-10-25 20:40:51
阅读次数:
255
Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except...
分类:
其他好文 时间:
2015-10-25 16:11:08
阅读次数:
190
public static int binary_search(int[] A, int key, int imin, int imax) { // continue searching while [imin,imax] is not empty while ...
分类:
其他好文 时间:
2015-10-25 13:44:21
阅读次数:
167
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
分类:
其他好文 时间:
2015-10-25 13:36:39
阅读次数:
131
http://openscenegraph.alphapixel.com/osg/downloads/free-openscenegraph-binary-downloads提供了OSG的各种编译好的版本,直接下载解压,将Bin目录加到Path中去就可以用,也可以将Data目录加到环境变量中去,.....
分类:
其他好文 时间:
2015-10-25 09:35:46
阅读次数:
311
package cn.edu.xidian.sselab;/*** Given a binary tree, find its maximum depth.* The maximum depth is the number of nodes along the longest path from t...
分类:
其他好文 时间:
2015-10-24 23:32:01
阅读次数:
262
Problem StatementLet's say you have a binary string such as the following:011100011One way to encrypt this string is to add to each digit the sum of i...
分类:
其他好文 时间:
2015-10-24 18:52:40
阅读次数:
269