LeetCode DFS
文章平均质量分 71
Haskei
这个作者很懒,什么都没留下…
展开
-
[Leetcode] 51. N-Queens N皇后问题 (DFS)
51.N-Queens (题目链接)HardThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinct solutions to then-queens puzzle.Each solution contains a distinc...原创 2020-08-13 12:18:26 · 162 阅读 · 0 评论 -
[leetcode] 47. Permutations II 全排列去重
47.Permutations II (题目链接)MediumGiven 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]]class Solution: def permuteUnique(self..原创 2020-08-13 11:19:22 · 121 阅读 · 0 评论 -
[Leetcode] 1278. Palindrome Partitioning III (DFS / 动态规划)
1278.Palindrome Partitioning III (题目链接)HardYou are given a stringscontaining lowercase letters and an integerk. You need to :First, change some characters ofsto other lowercase English letters. Then dividesintoknon-empty disjoint substring...原创 2020-08-12 18:41:16 · 168 阅读 · 0 评论 -
[Leetcode] 131. Palindrome Partitioning 分割字符串
131.Palindrome Partitioning (题目链接)MediumGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.Example:Input:"aab"Output:[ ["aa","b"], ["a","a","b"]]...原创 2020-08-12 14:59:00 · 175 阅读 · 0 评论 -
[Leetcode] 863. All Nodes Distance K in Binary Tree 找出距离某个点距离为k的所有的点
863.All Nodes Distance K in Binary Tree (题目链接)MediumWe are given a binary tree (with root noderoot), atargetnode, and an integer valueK.Return a list of the values of allnodes that have a distanceKfrom thetargetnode. The answer can be retu...原创 2020-08-12 11:08:21 · 130 阅读 · 0 评论 -
[Leetcode] 90. Subsets II 求所有的子集,包含重复元素
90.Subsets II (题目链接)Medium172375Add to ListShareGiven 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]O...原创 2020-08-11 11:38:28 · 139 阅读 · 0 评论 -
[Leetcode] 40. Combination Sum II (DFS)
40.Combination Sum II (题目链接)MediumGiven a collection of candidate numbers (candidates) and a target number (target), find all unique combinations incandidateswhere the candidate numbers sums totarget.Each number incandidatesmay only be usedonc...原创 2020-08-11 02:32:41 · 144 阅读 · 0 评论