分类:全部列表
[LeetCode]78.Subsets子集合Givenasetofdistinctintegers, S,returnallpossiblesubsets.Note:Elementsinasubsetmustbeinnon-descendingorder.Thesolutionsetmustnotcontainduplicatesubsets.Forexample,If S = [1,2,3],asolutionis:[[3],[1],[2],[1,2,3],[1,3],[2,3],[1,2],[]]这道求子集合的问题,由于其要列出所有结果,按照以往的经验,肯定要是要用递归来做。这道...
继续阅读 >
[LeetCode]47.PermutationsII全排列之二Givenacollectionofnumbersthatmightcontainduplicates,returnallpossibleuniquepermutations.Example:Input:[1,1,2]Output:[[1,1,2],[1,2,1],[2,1,1]]这道题是之前那道 Permutations 的延伸,由于输入数组有可能出现重复数字,如果按照之前的算法运算,会有重复排列产生,我们要避免重复的产生,在递归函数中要判断前面一个数和当前的数是否相等,如果相等,且...
继续阅读 >
[LeetCode]90.SubsetsII子集合之二Givenacollectionofintegersthatmightcontainduplicates, S,returnallpossiblesubsets.Note:Elementsinasubsetmustbeinnon-descendingorder.Thesolutionsetmustnotcontainduplicatesubsets.Forexample,If S = [1,2,2],asolutionis:[[2],[1],[1,2,2],[2,2],[1,2],[]]这道子集合之二是之前那道 Subsets 的延伸,这次输入...
继续阅读 >