摘要: 解题思路: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) 编辑