Subsets II | Backtracking (opens in new tab)
leetcode.com Problem Statement Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution must not contain duplicate subsets. Brute Force Intuition Generate all possible subsets using the classic Pick / Not Pick recursion. After generating every subset, store them in a Set to remove duplicates. While this works, many duplicate subsets are generated unnecessarily and later filtered out. Complexity Time Complexity: O(2ᴺ × N) Space Complexi...
Read the original article