Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n... ...
分类:
其他好文 时间:
2017-06-18 11:57:14
阅读次数:
202
题意:根据二叉树的中序遍历和后序遍历恢复二叉树。 解题思路:看到树首先想到要用递归来解题。以这道题为例:如果一颗二叉树为{1,2,3,4,5,6,7},则中序遍历为{4,2,5,1,6,3,7},后序遍历为{4,5,2,6,7,3,1},我们可以反推回去。由于后序遍历的最后一个节点就是树的根。也就是 ...
分类:
其他好文 时间:
2017-06-18 00:05:04
阅读次数:
158
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should ...
分类:
其他好文 时间:
2017-06-17 22:39:58
阅读次数:
196
124. Binary Tree Maximum Path Sum 题目链接:https://leetcode.com/problems/binary-tree-maximum-path-sum/#/description 题目大意:给定一棵二叉树,查找该二叉树的最大路径和。路径的定义是,从某个结点 ...
分类:
其他好文 时间:
2017-06-17 20:47:29
阅读次数:
154
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' ...
分类:
其他好文 时间:
2017-06-17 20:40:04
阅读次数:
154
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r ...
分类:
其他好文 时间:
2017-06-17 17:01:19
阅读次数:
164
https://leetcode.com/problems/binary-tree-level-order-traversal-ii/#/solutions 这题跟层序遍历没有什么不同,只是把最后结果reverse 一下而已。不知道还有没有其他的套路? 可以分别用BFS 和DFS,后者要更简洁一点。 ...
分类:
其他好文 时间:
2017-06-17 14:20:15
阅读次数:
143
首先声明:我们要构建的是扩展或者模块名为hello_module.该模块提供一个方法:hello_word. 一、PHP环境的搭建 1)一般使用源码包编译安装,而不是binary包安装。因为使用PHP的二进制分发包安装有些冒险,这些版本倾向于忽略./configure的两个重要选项,它们在开发过程中 ...
分类:
Web程序 时间:
2017-06-17 12:10:24
阅读次数:
187
题目: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null n ...
分类:
编程语言 时间:
2017-06-17 11:09:39
阅读次数:
228
题目: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return t ...
分类:
编程语言 时间:
2017-06-16 21:16:59
阅读次数:
175