方法一:若是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
java: cannot execute binary file问题主要原因是 linux系统是32位的,jdk版本是64位的.补充知识:1、查看linux位数: #uname -a 如果有x86_64就是64位的,没有就是32位的 这是64位的 # uname -a Linux desktop 2...
分类:
系统相关 时间:
2015-01-20 20:08:01
阅读次数:
175
The problem:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each...
分类:
其他好文 时间:
2015-01-20 15:03:56
阅读次数:
95
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:
其他好文 时间:
2015-01-20 13:36:44
阅读次数:
172