From 84974a909c253d93d373617577383839020d83b9 Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Wed, 22 Apr 2026 21:13:48 -0400 Subject: [PATCH 1/4] problem 3 soln --- water.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 water.py diff --git a/water.py b/water.py new file mode 100644 index 00000000..9c186fa4 --- /dev/null +++ b/water.py @@ -0,0 +1,27 @@ +# // Time Complexity : O(n) +# // Space Complexity : O(1) +# // Did this code successfully run on Leetcode : Yes +# // Any problem you faced while coding this : No + +class Solution(object): + def maxArea(self, height): + """ + :type height: List[int] + :rtype: int + """ + + res=0 + start=0 + end=len(height)-1 + + while start Date: Wed, 22 Apr 2026 22:35:20 -0400 Subject: [PATCH 2/4] problem 1 soln --- sort.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sort.py diff --git a/sort.py b/sort.py new file mode 100644 index 00000000..7ad70c8c --- /dev/null +++ b/sort.py @@ -0,0 +1,26 @@ +# // Time Complexity : O(n) +# // Space Complexity : O(1) +# // Did this code successfully run on Leetcode : Yes +# // Any problem you faced while coding this : idea to inplace sorting did not come to me until class. + +class Solution(object): + def sortColors(self, nums): + """ + :type nums: List[int] + :rtype: None Do not return anything, modify nums in-place instead. + """ + low=0 + mid=0 + high=len(nums)-1 + + while( mid<=high): + if nums[mid]==0: + nums[low],nums[mid]=nums[mid],nums[low] + low+=1 + mid+=1 + elif nums[mid]==2: + nums[high],nums[mid]=nums[mid],nums[high] + high-=1 + else: + mid+=1 + \ No newline at end of file From 7136d49e2ce41f2c07a9678ce3ddaa5d0b6a45e2 Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Wed, 22 Apr 2026 23:16:38 -0400 Subject: [PATCH 3/4] problem 3 soln --- 3sum.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 3sum.py diff --git a/3sum.py b/3sum.py new file mode 100644 index 00000000..fcac8d76 --- /dev/null +++ b/3sum.py @@ -0,0 +1,37 @@ +# // Time Complexity : O(nlogn + n^2) => O(n^2) +# // Space Complexity : sorting takes O(n) +# // Did this code successfully run on Leetcode : Yes +# // Any problem you faced while coding this : I was trying to do twosum with just rest of the array and taregt as 0-nums[i]. +# It was hard to get to the point where I should try and form the result set of 3 numbers while handling 2 sum, instead of just getting the 2 nums other than i and then figuring out to remove duplicates. + +class Solution(object): + def threeSum(self, nums): + """ + :type nums: List[int] + :rtype: List[List[int]] + """ + resultset=[] + nums.sort() + i=0 + while i0: break + if i!=0 and nums[i-1]==nums[i]: + i+=1 + else: + start=i+1 + end=len(nums)-1 + while start< end: + s=nums[i]+nums[start]+nums[end] + if s==0: + resultset.append([nums[i],nums[start],nums[end]]) + start+=1 + end-=1 + while start Date: Wed, 22 Apr 2026 23:18:02 -0400 Subject: [PATCH 4/4] Renaming files --- water.py => maxwater.py | 0 sort.py => sortcolors.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename water.py => maxwater.py (100%) rename sort.py => sortcolors.py (100%) diff --git a/water.py b/maxwater.py similarity index 100% rename from water.py rename to maxwater.py diff --git a/sort.py b/sortcolors.py similarity index 100% rename from sort.py rename to sortcolors.py