上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 72 下一页
摘要: 解题思路:1.DFS 和回溯算法区别DFS 是一个劲的往某一个方向搜索,而回溯算法建立在 DFS 基础之上的,但不同的是在搜索过程中,达到结束条件后,恢复状态,回溯上一层,再次搜索。因此回溯算法与 DFS 的区别就是有无状态重置 2.何时使用回溯算法当问题需要 "回头",以此来查找出所有的解的时候, 阅读全文
posted @ 2018-04-21 20:15 乐乐章 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 40. 组合总和 II labuladong 题解 难度中等 1353 给定一个候选人编号的集合 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用 一次 。 注意:解集 阅读全文
posted @ 2018-04-21 17:46 乐乐章 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 39. 组合总和 labuladong 题解思路 难度中等 2493 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。 阅读全文
posted @ 2018-04-21 17:26 乐乐章 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文
posted @ 2018-04-21 17:11 乐乐章 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], 阅读全文
posted @ 2018-04-21 16:24 乐乐章 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2018-04-20 17:03 乐乐章 阅读(505) 评论(0) 推荐(0) 编辑
摘要: Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2018-04-18 11:14 乐乐章 阅读(692) 评论(0) 推荐(0) 编辑
摘要: 与 最长公共子序列类似 只是最长公共子串必须连续 所以只能走斜线!!!! 阅读全文
posted @ 2018-04-18 08:50 乐乐章 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 区别最长公共子串(连续) 阅读全文
posted @ 2018-04-17 17:40 乐乐章 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目: 长度为N的数组A中子数组和最接近0的子数组。 思路: 对于一个数组A,其子数组和最接近0只会出现在两种情况中: 如何做? 申请同样长度的空间sum[0…N-1],sum[i]是A的前i项和。  Trick:定义sum[-1] = 0  显然有:  算法:  对sum[0…N-1]排序 阅读全文
posted @ 2018-04-16 22:47 乐乐章 阅读(400) 评论(0) 推荐(0) 编辑
上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 72 下一页