JS clean solution
\n/**\n * @param {number[]} nums\n * @return {number[][]}\n */\nvar subsetsWithDup = function(nums) {\n    const result = [];\n    nums.sort();\n    \n    const
```\n/**\n * @param {number[]} nums\n * @return {number[][]}\n */\nvar subsetsWithDup = function(nums) {\n    const result = [];\n    nums.sort();\n    \n    const dfs = (arr, i) => {\n        if (i === nums.length) {\n            result.push(arr);\n            return;\n        }\n        // take the current number\n        dfs([...arr, nums[i]], i+1);\n        // while not at end of array and duplicate after current number\n        while (i+1 < nums.length && nums[i] === nums[i + 1]) {\n            i++;\n        }\n        // leave the current number\n        dfs([...arr], i+1);\n    }\n    \n    dfs([], 0);\n    return result;\n};\n```\n\nshoutout neetcode
['Backtracking', 'Recursion', 'JavaScript']