- eg: all the subsets of [1,2,2,3]
- subset of size 0: []
- subset of size 1: [1] [2]
[2 ][3] - subset of size 2: [1,2]
[1,2][1,3] [2,2] [2,3] - subset of size 3: [1,2,2] [1,2,3] [2,2,3]
- repeatedly add one succeeding number (if it is not repeating) to each element of the previous set
- avoid duplicates by comparing successive numbers
[1] https://leetcode.com/problems/subsets-ii/
OJ
No comments:
Post a Comment