先是中序遍历
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
clas...
分类:
其他好文 时间:
2015-01-21 22:30:18
阅读次数:
211
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:
其他好文 时间:
2015-01-21 22:12:18
阅读次数:
246
1.什么是二叉排序树?二叉排序树(Binary Sort Tree)又称二叉查找树(Binary Search Tree),亦称二叉搜索树。 它或者是一棵空树;或者是具有下列性质的二叉树:(1)若左子树不空,则左子树上所有结点的值均小于它的根结点的值;(2)若右子树不空,则右子树上所有结点的值均大于...
分类:
编程语言 时间:
2015-01-21 19:40:48
阅读次数:
224
方法一:若是bst,中序便利后一定是有序,递增的。可以中序遍历后查看是否递增来判断 1 class Solution { 2 public: 3 bool isValidBST(TreeNode *root) { 4 5 if...
分类:
其他好文 时间:
2015-01-21 14:52:29
阅读次数:
215
传送门:https://oj.leetcode.com/problems/binary-tree-level-order-traversal/Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, ...
分类:
其他好文 时间:
2015-01-21 13:22:25
阅读次数:
151
原题地址假设我们找到了一个最优路径,那么该路径上一定存在一个节点,左边的路径是它的左儿子,右边的路径是它的右儿子。所以,只需要在遍历二叉树求路径的同时更新最大值即可。maxPath = max{只保留左边路径,只保留右边路径,同时保留左右两边路径,左右两边路径都不保留(只有节点本身)},对应第8行无...
分类:
其他好文 时间:
2015-01-21 13:18:39
阅读次数:
118
Problem:
You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum to a given value. The path does not need to start or end at the root or a le...
分类:
编程语言 时间:
2015-01-21 09:01:33
阅读次数:
161
此文主要讲述 Java 运行 Selenium 脚本时,因 Friefox 浏览器版本与selenium-server-standalone-x.xx.x.jar 不兼容引起的org.openqa.selenium.WebDriverException: Failed to connect to b...
分类:
Web程序 时间:
2015-01-20 23:44:28
阅读次数:
716
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:递归的思路。思路与重建二叉树类似。时间复杂度O(n), 空间复杂度O(logN) 1 /** 2 ....
分类:
其他好文 时间:
2015-01-20 22:00:43
阅读次数:
170
Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.使用dpHeight[]数组来记...
分类:
其他好文 时间:
2015-01-20 21:45:37
阅读次数:
199