摘要: 分治法的基本思想:将一个规模为n的问题分解为k个规模较小的子问题,这些子问题互相独立且与原问题相同。递归地解这些问题,然后将各个子问题的解合并成原问题的解。 分治法所能解决的问题一般具有以下几个特征: 该问题的规模缩小到一定的程度就可以容易地解决;因为问题的计算复杂性一般是随着问题规模的增加而增加, 阅读全文
posted @ 2017-07-25 22:44 apanda009 阅读(11476) 评论(0) 推荐(0) 编辑
摘要: public class MyNode { TreeNode node; int start; int end; public MyNode(TreeNode node, int start, int end) { this.node = node; this.start = start; this 阅读全文
posted @ 2017-07-25 22:39 apanda009 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 递归出口1, 出口2(操作, 遍历(dfs), 操作), 操作, 遍历(dfs), 操作 阅读全文
posted @ 2017-07-25 18:36 apanda009 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 从任意一点dfs, 和dfs return 当前, 左节点, 右节点的模板 The basic idea is to subtract the value of current node from sum until the subtraction equals 0, then we know th 阅读全文
posted @ 2017-07-25 13:31 apanda009 阅读(124) 评论(0) 推荐(0) 编辑