From 3dbf6f4ff415a44e83c94aed4c9877c38322c03d Mon Sep 17 00:00:00 2001 From: snehashukkla <72079302+snehashukkla@users.noreply.github.com> Date: Mon, 4 Oct 2021 23:39:26 +0530 Subject: [PATCH] Create 78-Subsets.py --- Python/78-Subsets.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Python/78-Subsets.py diff --git a/Python/78-Subsets.py b/Python/78-Subsets.py new file mode 100644 index 0000000..36373e7 --- /dev/null +++ b/Python/78-Subsets.py @@ -0,0 +1,21 @@ +#link to problem:https://leetcode.com/problems/subsets/ + + #code + + class Solution: + def subsets(self, nums: List[int]) -> List[List[int]]: + + res = [] + + + def solve(v = [], ind = 0): + + if ind == len(nums): + res.append(v) + return + + solve(v + [nums[ind]], ind + 1) # pick + solve(v, ind + 1) # non-pick + + solve() + return res