Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath betwee ...
分类:
其他好文 时间:
2017-03-23 21:22:24
阅读次数:
174
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NUL... ...
分类:
其他好文 时间:
2017-03-23 20:42:53
阅读次数:
498
一、描述: 二、思路: 二叉树或一般树的水平层次遍历,可以使用BFS(广度搜素)算法,使用队列Queue标记每一层的结点元素; Queue:先进先出, 后进后出。可以保证每一层遍历时的结点顺序; BFS:类似于电影中的病毒传染,先感染靠近自己的,再由易感染层感染更外层…(我理解的就是这么个理); 该 ...
分类:
其他好文 时间:
2017-03-23 19:12:23
阅读次数:
157
Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th ...
分类:
其他好文 时间:
2017-03-23 16:39:09
阅读次数:
133
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive sol ...
分类:
其他好文 时间:
2017-03-23 13:48:46
阅读次数:
120
一、描述: 二、思路: 属于二叉树类型,使用递归解决; 返回false:一棵树为空,且另一棵树不为空; 返回true两种情况:1两棵树均为空;2两棵树均不为空,且对应位置的结点完全相同; 递归调用,两树均为空是递归结束条件。 三、代码: ...
分类:
其他好文 时间:
2017-03-23 02:02:12
阅读次数:
118
题意:俩智障又在玩游戏。规则如下: 给定n个点,m条无向边(m<=n-1),保证无环,对于每一个联通块,编号最小的为它们的根(也就是形成了一片这样的森林),每次可以选择一个点,将其本身与其祖先全部删除,不能操作者输。判断先手胜负。 题解:比较神的一道题。 我们现在要解决的问题是怎么求解一棵子树的SG ...
分类:
其他好文 时间:
2017-03-22 23:01:02
阅读次数:
276
packagecom.jh.hiv.test.service.test;importjava.io.UnsupportedEncodingException;importorg.apache.commons.codec.digest.DigestUtils;importorg.apache.commons.codec.binary.Base64;importorg.junit.Test;publicclasstest12{staticfinalStringTARGET="changeme";/**不可逆..
分类:
编程语言 时间:
2017-03-22 13:32:31
阅读次数:
191
538. Convert BST to Greater Tree 538. Convert BST to Greater Tree Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key o ...
分类:
其他好文 时间:
2017-03-22 10:33:19
阅读次数:
147
Leetcode-543-Diameter of Binary Tree 543. Diameter of Binary Tree Add to List 543. Diameter of Binary Tree Add to List Add to List DescriptionSubmissi ...
分类:
其他好文 时间:
2017-03-21 23:02:29
阅读次数:
287