具体思路参见:二叉树的非递归遍历(转)/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int...
分类:
其他好文 时间:
2014-11-10 11:47:59
阅读次数:
157
一个生成树构造成另一个生成树,可以不断的去边又加边来完成。 而这题全部边权为0,1,所以加边去边过程是+1 +1 的;
可以求出生成树 最大边权和 ,及最小的边权和。 然后枚举24个 小于100000的斐波那契数。如果无法成树,那直接可以判断是no的;
只要有某个斐波那契数 fb, fb=最小边权和 那就是可以构成这样一颗树的;...
分类:
其他好文 时间:
2014-11-10 10:09:40
阅读次数:
211
///白边优先和黑边优先做两次最小生成树
///若有斐波那契树在这中间为yes
# include
# include
# include
# include
# include
using namespace std;
struct node
{
int x;
int y;
int v;
};
struct node a[100010];
int father[...
分类:
其他好文 时间:
2014-11-10 10:08:22
阅读次数:
139
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.Solution: 1 public class Solution...
分类:
其他好文 时间:
2014-11-10 06:32:28
阅读次数:
202
本文源码托管于github上cmake_demo
cmake中一些预定义变量
PROJECT_SOURCE_DIR 工程的根目录PROJECT_BINARY_DIR 运行cmake命令的目录,通常是${PROJECT_SOURCE_DIR}/buildCMAKE_INCLUDE_PATH 环境变量,非cmake变量CMAKE_LIBRARY_PATH 环境变量CMAKE_CURRE...
分类:
其他好文 时间:
2014-11-10 01:11:21
阅读次数:
294
#include#includeusing namespace std;struct BinaryTree{ int count;// 该节点的孩子总数 int from_score; int to_score; BinaryTree* left; BinaryTree* right; Binary...
分类:
编程语言 时间:
2014-11-10 01:01:41
阅读次数:
214
Sum Root to Leaf Numbers
Total Accepted: 26533 Total
Submissions: 89186My Submissions
Question
Solution
Given a binary tree containing digits from 0-9 only,
each root-to-leaf pa...
分类:
其他好文 时间:
2014-11-09 23:53:10
阅读次数:
244
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...
分类:
其他好文 时间:
2014-11-09 23:41:43
阅读次数:
201
Given a binary tree, a target node in the binary tree, and an integer value k, print all the nodes that are at distance k from the given target node. ...
分类:
其他好文 时间:
2014-11-09 23:30:26
阅读次数:
235
题意:找到离根结点最近的叶子结点的那一层(设同一层上的结点与根结点的距离相等),返回它所在的层数。方法有:1、递归深度搜索2、层次搜索方法一:递归(无优化) 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * i...
分类:
其他好文 时间:
2014-11-09 22:12:11
阅读次数:
184