class Solution {
public:
vector postorderTraversal(TreeNode *root) {
vector res;
stack>s;
TreeNode *p = root;
while(p!=NULL||!s.empty())
{
while...
分类:
其他好文 时间:
2015-04-02 19:02:48
阅读次数:
117
class Solution {
public:
vector preorderTraversal(TreeNode *root) {
vector res;
stack s;
TreeNode * p = root;
while(p!=NULL||!s.empty())
{
while...
分类:
其他好文 时间:
2015-04-02 19:02:38
阅读次数:
131
class Solution {
public:
vector inorderTraversal(TreeNode *root) {
vector res;
stack s;
TreeNode * p = root;
while(p!=NULL||!s.empty())
{
while(...
分类:
其他好文 时间:
2015-04-02 19:01:33
阅读次数:
98
Exec_Master_Log_Pos: The position of the last event executed by the SQL thread from the master's binary log (Relay_Master_Log_File). (Relay_Master_L.....
分类:
数据库 时间:
2015-04-02 18:31:50
阅读次数:
134
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =...
分类:
其他好文 时间:
2015-04-02 15:01:01
阅读次数:
112
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-04-02 14:48:37
阅读次数:
163
题目链接:https://leetcode.com/problems/validate-binary-search-tree/
就是判断一个给定的二叉树是否为二叉查找树。
我的思路是:先将该树中序遍历一遍,按中序遍历的顺序保存到一个vector中,然后判断vector中的顺序即可。
代码:
class Solution {
public:
void inOrder(TreeNode...
分类:
其他好文 时间:
2015-04-02 10:29:28
阅读次数:
107
判断是否为二叉搜索树
定义上下确界
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
*...
分类:
其他好文 时间:
2015-04-01 23:51:43
阅读次数:
130
Vanya decided to walk in the field of size n?×?n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi,?yi)...
分类:
其他好文 时间:
2015-04-01 23:19:33
阅读次数:
113
题目:
Given a binary tree, return the preorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},1
\
2
/
3return [1,2,3].Note: Recursive solution is triv...
分类:
其他好文 时间:
2015-04-01 21:56:42
阅读次数:
96