78. Subsets
# Medium
Last updated
Was this helpful?
# Medium
Last updated
Was this helpful?
Subset problems are generally solved by RECURSIVE.
Build subsets from NULL, add one element whose positioin is after current element each time.
In Python, list.append(sublist)
in helper function gets wrong output(list = [[], [], [], [], []]
), should be list.append(sublist[:]).
After each sub.append
, must remove that element just added in helper function.
Time complexity = , is to copy the subset to result.
Space complexity =