Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN...
分类:
其他好文 时间:
2015-04-12 20:38:48
阅读次数:
159
好久不写了,最近忙毕业论文呢。这个题,就是说一个二叉树,你从右边看,你能看到的数有哪些(会被遮挡)其实抽象出来就是说。。。二叉树每层最右边的数有哪些。。那我们按层遍历一次就好了。/** * Definition for binary tree * struct TreeNode { * in...
分类:
其他好文 时间:
2015-04-12 20:37:02
阅读次数:
110
题目:An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with ...
分类:
其他好文 时间:
2015-04-12 16:06:42
阅读次数:
107
一:LeetCode 105 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 d...
分类:
其他好文 时间:
2015-04-12 14:50:20
阅读次数:
117
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:
其他好文 时间:
2015-04-12 14:38:25
阅读次数:
134
题目链接:maximal-rectangle
import java.util.Arrays;
/**
* Given a 2D binary matrix filled with 0's and 1's,
* find the largest rectangle containing all ones and return its area.
*
*/
public cl...
分类:
其他好文 时间:
2015-04-12 13:28:40
阅读次数:
189
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
其他好文 时间:
2015-04-12 11:48:52
阅读次数:
100
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
For example:
Given the following binary tree,
1 ...
分类:
其他好文 时间:
2015-04-12 10:41:52
阅读次数:
149
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
题意:求0,1矩阵中,1构成的最大矩阵。
思路:借用了上一题,首先我们先计算出dp[i][j]表示到第i行第j列时,此时这一列的连续1的个数,然后计算每一行...
分类:
其他好文 时间:
2015-04-12 10:37:34
阅读次数:
118
Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered fr...
分类:
其他好文 时间:
2015-04-11 19:09:34
阅读次数:
124