From 2d0c2b64f5da08ff7e539a8909512a52eb13cd6a Mon Sep 17 00:00:00 2001 From: Adithya Vinayak Date: Sun, 29 Mar 2026 16:09:25 -0400 Subject: [PATCH 1/2] working solution --- problem1.py | 20 ++++++++++++++++++++ problem2.py | 0 2 files changed, 20 insertions(+) create mode 100644 problem1.py create mode 100644 problem2.py diff --git a/problem1.py b/problem1.py new file mode 100644 index 00000000..e2868b51 --- /dev/null +++ b/problem1.py @@ -0,0 +1,20 @@ +# problem 1 +# https://leetcode.com/problems/subsets/ + +class Solution: + def subsets(self, nums: List[int]) -> List[List[int]]: + self.final_arr = [] + self.nums = nums + self.path = [] + self.helper(0) + return self.final_arr + + + def helper(self,i): + if i == len(self.nums): + self.final_arr.append(self.path.copy()) + return + self.helper(i+1) + self.path.append(self.nums[i]) + self.helper(i+1) + self.path.pop() diff --git a/problem2.py b/problem2.py new file mode 100644 index 00000000..e69de29b From e78757cd17eabaaa243b9fa95ebf2118d6fd421b Mon Sep 17 00:00:00 2001 From: Adithya Vinayak Date: Sun, 29 Mar 2026 16:10:57 -0400 Subject: [PATCH 2/2] working solution --- problem2.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/problem2.py b/problem2.py index e69de29b..635f7b94 100644 --- a/problem2.py +++ b/problem2.py @@ -0,0 +1,29 @@ +# problem 2 + +# https://leetcode.com/problems/palindrome-partitioning/ +class Solution: + def partition(self, s: str) -> List[List[str]]: + self.final_arr = [] + self.helper(s,0,[]) + return self.final_arr + + def helper(self,s,pivot,path): + if pivot == len(s): + self.final_arr.append(list(path)) + return + for i in range(pivot,len(s)): + sub_str = s[pivot:i+1] + if self.isPalindrome(sub_str): + path.append(sub_str) + self.helper(s,i+1,path) + path.pop() + + def isPalindrome(self,ip_str): + i = 0 + j = len(ip_str)-1 + while(i