Advertisement
rishu110067

Untitled

Jan 30th, 2022
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. class Solution:
  2.     def subsets(self, nums: List[int]) -> List[List[int]]:
  3.         ans=self.helper(nums,0,[],[])
  4.         return ans
  5.        
  6.        
  7.     def helper(self,input_chars,index,result,curr_soln):
  8.         if index==len(input_chars):
  9.             #print(curr_soln)
  10.             result.append(curr_soln.copy())
  11.             return
  12.        
  13.         self.helper(input_chars,index+1,result,curr_soln)
  14.         curr_soln.append(input_chars[index])
  15.         self.helper(input_chars,index+1,result,curr_soln)
  16.         curr_soln.pop()
  17.         return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement