回溯
zyp7355
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode回溯法总结
第二遍做leetcode 中的回溯法, 发现不光没有更好的理解,甚至遗忘了很多。 所以今天觉得做一篇有关回溯法的总结 首先,回溯法的基本思想:从一条路往前走,能进则进,不能进则退回,换一条路再试 回溯法的基本定义和概念 首先要明确下面三个概念 1约束函数:约束函数是根据题意定出, 通过描述合法解的一般特征用于去除不合法的解,从而避免继续搜索出这个不合法解的剩余部分 2状态空间树 状态空间树是一个对...原创 2020-04-02 04:14:49 · 217 阅读 · 0 评论 -
leetcode #17. Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is give...原创 2020-03-20 09:01:55 · 128 阅读 · 0 评论 -
leetcode #131 Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example: Input: “aab” Output: [ [“aa”,“b”], [“a”,“a”,“b”] ] ...原创 2020-03-04 12:01:58 · 123 阅读 · 0 评论 -
leetcode#113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 ...原创 2020-02-28 04:19:27 · 129 阅读 · 0 评论 -
leetcode#90. Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Example: Input: [1,2,2] Outp...原创 2020-02-21 06:32:48 · 117 阅读 · 0 评论 -
leetcode # 78 subset
Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Example: Input: nums = [1,2,3] Output: [ [3], [1], [2], ...原创 2020-02-19 09:36:24 · 118 阅读 · 0 评论 -
leetcode #77 combination
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], [1,2], [1,3], [1,4], ] 看到这种排列的题目 第一想到就是backtracking ...原创 2020-02-19 07:35:19 · 207 阅读 · 0 评论 -
leetcode#47
Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: Input: [1,1,2] Output: [ [1,1,2], [1,2,1], [2,1,1] ] 思路 backtracking 和第36题一样 但是多一个去重 首先将数...原创 2020-02-11 06:56:06 · 77 阅读 · 0 评论 -
leetcode#39
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. The same repeate...原创 2020-02-09 03:31:52 · 114 阅读 · 0 评论
分享