Subset Sum II

Subsequences Pattern DSA practice problem on Onlearn.

Difficulty: medium.

Topics: Return all unique subsets of an array that may contain duplicates, Arrays, Recursion, Backtracking, Set, Sorting, Time Complexity, Space Complexity, Subsequences, sorting algorithms, backtracking, combinatorics, set, duplicate handling, recursion, time complexity analysis, Subset & Permutation Problems, Sets & Hash Sets.

Given an array of integers that may contain duplicates, the task is to return all possible unique subsets. The subsets can be in any order. Example 1: Input: array[] = [1,2,2] Output: [ [ ],[1],[1,2],[1,2,2],[2],[2,2] ] Explanation: We can have subsets ranging from length 0 to 3. Also, the subset [1,2] appears twice but is printed only once as only unique subsets are required. Example 2: Input: array[] = [1] Output: [ [ ], [1] ] Explanation: Only two unique subsets are available.