Subsets II
You get a list of numbers, and some of them may repeat. Return every different subset: every group you can pick, from none of the numbers to all of them, with no group twice, even when equal numbers make it in another way. Our example: [3, 1, 3] has 6 such subsets: [ ], [1], [1, 3], [1, 3, 3], [3] and [3, 3].
- input
nums: integers; some of them may repeat.- returns
- Every different subset of
nums: every group of its numbers you can pick, from none of them to all of them, with no group twice, even when equal numbers make it in another way. Subsets in any order, numbers in a subset too. - constraints
- 1 ≤ nums.length ≤ 10
- −10 ≤ nums[i] ≤ 10
- examples
- Open a test in the tests panel: it shows the input and the expected answer.
/**
* @param {number[]} nums
* @return {number[][]}
*/
function subsetsWithDup(nums) {
}
Ctrl ↵
format
reset
saved in this browser
Stuck?
See the solution run step by step on our example, then why it works and its complexity.
Next: more backtracking problems
The problem and its statement belong to LeetCode. Here are our own retelling, example and solution. Patterns Hero is not affiliated with LeetCode.