From 8b2cea440c420b906741cb7c14e33fab46ef6d86 Mon Sep 17 00:00:00 2001 From: Sejal Jagtap Date: Fri, 31 Oct 2025 08:37:15 -0500 Subject: [PATCH 1/2] Problem 1.py --- Problem 1.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Problem 1.py diff --git a/Problem 1.py b/Problem 1.py new file mode 100644 index 00000000..9c1a0758 --- /dev/null +++ b/Problem 1.py @@ -0,0 +1,19 @@ +class Solution: + def subsets(self, nums: List[int]) -> List[List[int]]: + res = [] + n = len(nums) + def backtrack(i, sofar): + if i>n: + return + + + #res.append(sofar.copy()) + print(sofar) + + for j in range(i, n): + sofar.append(nums[j]) + backtrack(j+1,sofar) + sofar.pop() + + backtrack(0, []) + return res From 5f9921a4ed4eb8d05803def814788c2840461b5b Mon Sep 17 00:00:00 2001 From: Sejal Jagtap Date: Fri, 31 Oct 2025 08:37:44 -0500 Subject: [PATCH 2/2] Problem 2.py --- Problem 2.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Problem 2.py diff --git a/Problem 2.py b/Problem 2.py new file mode 100644 index 00000000..398523ba --- /dev/null +++ b/Problem 2.py @@ -0,0 +1,23 @@ +class Solution: + def partition(self, s: str) -> List[List[str]]: + + def ispalin(string): #true or False + return string[::-1]==string + + n = len(s) + res = [] + def backtrack(i, sofar): + if i>=n: + res.append(sofar.copy()) + #print(sofar) + return + + for j in range(i, n): + if ispalin(s[i:j+1]): + sofar.append(s[i:j+1]) + backtrack(j+1, sofar) + sofar.pop() + backtrack(0, []) + return res + +