easy peasy python [comments] best iterative solution
\t# pos dict helps to prevent duplicates\n\t# frm = position in res(result) from where I have to start adding the current num\n\t# to understand this code, firs
\t# pos dict helps to prevent duplicates\n\t# frm = position in res(result) from where I have to start adding the current num\n\t# to understand this code, first take example of [1,2,3], and then [1,2,2]\n\t# Basically, I add my current num to the all the lists already in the result\n\t# however to prevent duplicates, I note down the position of the result where I start adding my num\n\t# and next time when I see a duplicate I start from the position from where I added my first duplicate element instead from 0th position of the result \n\t\n\t\n\tdef subsetsWithDup(self, nums: List[int]) -> List[List[int]]:\n        res, pos, nums = [[]], {}, sorted(nums)\n        for n in nums:\n            frm, ln = pos.get(n, 0), len(res)\n            for ls in res[frm:]:\n                res.append(ls + [n])\n            pos[n] = ln\n            \n        return res
['Depth-First Search', 'Recursion', 'Iterator', 'Python', 'Python3']