如果按层次遍历,存下每一层的点,会MLE。1、递归版本:关键还是子问题的划分。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * ...
分类:
其他好文 时间:
2014-07-07 13:58:07
阅读次数:
181
判断一棵树是不是平衡二叉树,之前做过,还有点印象,用一个函数返回树的高度,如果是-1的话,就说明子树不平衡。1A很开心~ 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * T...
分类:
其他好文 时间:
2014-07-07 13:56:05
阅读次数:
180
Problem Description:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre...
分类:
其他好文 时间:
2014-07-07 13:27:35
阅读次数:
207
树状数组树状数组(Binary Indexed Tree(BIT), Fenwick Tree)是一个查询和改动复杂度都为log(n)的数据结构。主要用于查询随意两位之间的全部元素之和,可是每次仅仅能改动一个元素的值;经过简单改动能够在log(n)的复杂度下进行范围改动,可是这时仅仅能查询当中一个元...
分类:
其他好文 时间:
2014-07-07 13:13:05
阅读次数:
166
大家可以去我的Githup下载 https://github.com/simplyou/YJ-UIIView-/tree/master在设置尺寸的时候亲们有没有感觉很蛋疼啊,这里提供了一套分类,直接放进工程里,在PCH中包含头文件就能解决你蛋疼的问题;/**********************....
分类:
移动开发 时间:
2014-07-03 11:51:43
阅读次数:
352
做完这道题,只能说基本功很重要,数组中套数组就不会用了,过几天吧1做了,看自己到底等没。https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/import java.util.*;/** * Definition ...
分类:
编程语言 时间:
2014-07-01 13:30:53
阅读次数:
300
秒杀/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = ...
分类:
编程语言 时间:
2014-07-01 13:16:49
阅读次数:
174
https://oj.leetcode.com/problems/path-sum//** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNod...
分类:
编程语言 时间:
2014-07-01 13:09:20
阅读次数:
198
题目
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
/ \ 3 4 6
The flattened tree should look lik...
分类:
其他好文 时间:
2014-06-30 18:13:31
阅读次数:
229