Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth ...
分类:
其他好文 时间:
2017-08-01 19:24:31
阅读次数:
186
同 563 Binary Tree Tilt 返回值是局部最大值, 需要全局变量 分治: 后序遍历, 分治法返回到上一层时找到当前层的最大单子路径 . 全局变量看看本层的单子(左右子树)路径diameter 和是否大于全局变量来更新. ...
分类:
其他好文 时间:
2017-08-01 19:08:15
阅读次数:
149
/*binary-tree-postorder-traversal*/ /***************************/ /* Given a binary tree, return the postorder traversal of its nodes' values. For exa... ...
分类:
其他好文 时间:
2017-08-01 17:54:14
阅读次数:
145
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any oneof them. Two ...
分类:
其他好文 时间:
2017-08-01 16:34:37
阅读次数:
137
从二叉树的根节点出发,节点的遍历分为三个主要步骤:对当前节点进行操作(称为“访问”节点,或者根节点)、遍历左边子节点、遍历右边子节点。访问节点顺序的不同也就形成了不同的遍历方式。需要注意的是树的遍历通常使用递归的方法进行理解和实现,在访问元素时也需要使用递归的思想去理解。实际实现中对于前序和中序遍历 ...
分类:
其他好文 时间:
2017-08-01 15:46:13
阅读次数:
123
迭代器&生成器 迭代器 迭代器是访问集合元素的一种方式。迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束。迭代器只能往前不会后退,不过这也没什么,因为人们很少在迭代途中往后退。另外,迭代器的一大优点是不要求事先准备好整个迭代过程中所有的元素。迭代器仅仅在迭代到某个元素时才计算该元素, ...
分类:
其他好文 时间:
2017-08-01 15:42:31
阅读次数:
158
树的题首先找容器(是全局变量还是输入值的递归 ), 再确定是分治(多后序) 还是递归(多前序),确定递归出口: 是否需要是找叶节点(left && right == null) 作正常出口(此时是输入值的递归见 257. Binary Tree Paths), 是否需要改变树的结构(此题借助pre改 ...
分类:
其他好文 时间:
2017-08-01 14:45:10
阅读次数:
167
考察后序建树和递归出口的设置: return helper(nums, 0, nums.length - 1); if (start > end) return null, if (start == end) {T t = new T(nums[end]); root.left = null; ro ...
分类:
其他好文 时间:
2017-08-01 14:17:12
阅读次数:
200
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Note: /** * Definition for a bi ...
分类:
其他好文 时间:
2017-08-01 12:33:40
阅读次数:
182
mysql 创建函数的时候 报错 ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabl ...
分类:
数据库 时间:
2017-08-01 11:10:13
阅读次数:
241