描述:
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is f...
分类:
其他好文 时间:
2015-05-15 09:03:58
阅读次数:
134
题目: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...
分类:
其他好文 时间:
2015-05-15 09:01:13
阅读次数:
145
题目: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 ...
分类:
其他好文 时间:
2015-05-14 23:37:22
阅读次数:
159
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2015-05-14 23:24:41
阅读次数:
137
题目Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.思路对于上图的一个01矩阵。我们可以一行一行的分析,假设第三行,我们按列扫描,遇到0时,柱子断开,重新形成柱子,遇到1时柱子高度加一。这样的话,我们就可以把问题转换...
分类:
其他好文 时间:
2015-05-14 22:05:23
阅读次数:
137
Binary Search Tree 又叫二叉查找树,二叉排序树这是种什么样的树呢?其实就是根节点的左子树比根节点小 右子树比根节点大 同时 左子树和右子树也是二叉搜索树代码比较简单 基本用递归实现 比较好理解 只有删除带有左右子树的节点时比较难理解方法就是 直接在右子树找一个最小的节点 取代要被删...
分类:
编程语言 时间:
2015-05-14 18:08:35
阅读次数:
142
题目描述:
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary a...
分类:
其他好文 时间:
2015-05-14 16:30:40
阅读次数:
102
原题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 dep...
分类:
其他好文 时间:
2015-05-14 16:23:27
阅读次数:
132
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
分析;
此题是求二叉树的深度,(无所谓最大深度),用递归的方法很容...
分类:
其他好文 时间:
2015-05-14 14:18:49
阅读次数:
117