Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Here we are taking one subarray and then push all the current elments one by one
- '''
- class Solution:
- def subsets(self, arr):
- ans=[[]]
- for i in arr:
- new_subset=[]
- for subset in ans:
- new_subset.append(subset+[i])
- ans=ans+new_subset #'+' basically extend the array
- return ans
Advertisement
Add Comment
Please, Sign In to add comment