LeetCode[39] 组合总和

Problem:

给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。

candidates 中的数字可以无限制重复被选取。

说明:

  • 所有数字(包括 target)都是正整数。
  • 解集不能包含重复的组合。

示例 1: 输入:candidates = [2,3,6,7], target = 7, 所求解集为: [ [7], [2,2,3] ]

示例 2: 输入:candidates = [2,3,5], target = 8, 所求解集为: [ [2,2,2,2], [2,3,3], [3,5] ]

阅读更多

LeetCode[46] 全排列

Related Topics:
“数组”: https://leetcode.com/tag/array/
“回溯”: https://leetcode.com/tag/backtracking/
Similar Questions:
“下一个排列”: https://leetcode.com/problems/next-permutation/
“全排列 II”: https://leetcode.com/problems/permutations-ii/
“排列序列”: https://leetcode.com/problems/permutation-sequence/

“组合”: https://leetcode.com/problems/combinations/

Problem:

给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。

示例 1:

输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

示例 2:

输入:nums = [0,1]
输出:[[0,1],[1,0]]

示例 3:

输入:nums = [1]
输出:[[1]]

提示:

  • 1 <= nums.length <= 6
  • -10 <= nums[i] <= 10
  • nums 中的所有整数 互不相同
阅读更多