From 50f94065feffe8bf7a9714f4c78f10c6f2294fe5 Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Tue, 21 Apr 2026 21:20:18 -0400 Subject: [PATCH 1/4] soln for problem 1 --- findmissing.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 findmissing.py diff --git a/findmissing.py b/findmissing.py new file mode 100644 index 00000000..9ed5af49 --- /dev/null +++ b/findmissing.py @@ -0,0 +1,25 @@ +# // 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 findDisappearedNumbers(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + n=len(nums) + res=[] + + for i in range(n): + ind = abs(nums[i])-1 + if nums[ind]>0: + nums[ind]*=-1 + + for i in range(n): + if nums[i]>0: + res.append(i+1) + + + return res \ No newline at end of file From 4f8beadb2d094c5e22c3db23a596b9d99709c6dc Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Tue, 21 Apr 2026 22:29:34 -0400 Subject: [PATCH 2/4] soln prob2 --- gameOfLife.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 gameOfLife.py diff --git a/gameOfLife.py b/gameOfLife.py new file mode 100644 index 00000000..4127e64c --- /dev/null +++ b/gameOfLife.py @@ -0,0 +1,39 @@ +# // Time Complexity : O(m*n) +# // Space Complexity : O(1) +# // Did this code successfully run on Leetcode : Yes +# // Any problem you faced while coding this : NA +# +class Solution(object): + def gameOfLife(self, board): + """ + :type board: List[List[int]] + :rtype: None Do not return anything, modify board in-place instead. + """ + res=board + m=len(board) + n=len(board[0]) + surround=[(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1)] + + for i in range(m): + for j in range(n): + live_around=0 + for s in surround: + r=i+s[0] + c=j+s[1] + + if r=0 and c=0 and abs(board[r][c])==1: + live_around+=1 + + if board[i][j]==0 and live_around==3: + board[i][j]=2 + + if board[i][j]==1 and (live_around>3 or live_around<2): + board[i][j]*=-1 + + for i in range(m): + for j in range(n): + if board[i][j]<=0: + board[i][j]=0 + else: + board[i][j]=1 + From dde4f680f926a48a8779a19dbd6a096a0973e190 Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Tue, 21 Apr 2026 22:29:59 -0400 Subject: [PATCH 3/4] soln prob3 --- findminmax.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 findminmax.py diff --git a/findminmax.py b/findminmax.py new file mode 100644 index 00000000..585334be --- /dev/null +++ b/findminmax.py @@ -0,0 +1,34 @@ +# // Time Complexity : O(n) +# // Space Complexity : O(1) +# // Did this code successfully run on GeeksForGeeks : Yes +# // Any problem you faced while coding this : No + +class Solution: + def getMinMax(self, arr): + # code here + n=len(arr) + if n%2==1: + min_e=arr[0] + max_e=arr[0] + i=1 + else: + if arr[0]>arr[1]: + min_e=arr[1] + max_e=arr[0] + else: + min_e=arr[0] + max_e=arr[1] + i=2 + + + while(iarr[i+1]): + min_e=min(min_e,arr[i+1]) + max_e=max(max_e,arr[i]) + else: + min_e=min(min_e,arr[i]) + max_e=max(max_e,arr[i+1]) + i+=2 + + + return [min_e,max_e] \ No newline at end of file From 8d33b4db47d9a3e8e3194d3787319d478da06184 Mon Sep 17 00:00:00 2001 From: Shakthi Nandana Date: Tue, 21 Apr 2026 22:35:16 -0400 Subject: [PATCH 4/4] update --- findminmax.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/findminmax.py b/findminmax.py index 585334be..7c3221e5 100644 --- a/findminmax.py +++ b/findminmax.py @@ -7,20 +7,20 @@ class Solution: def getMinMax(self, arr): # code here n=len(arr) - if n%2==1: - min_e=arr[0] - max_e=arr[0] - i=1 - else: + if n%2==0: + start=2 if arr[0]>arr[1]: min_e=arr[1] max_e=arr[0] else: min_e=arr[0] max_e=arr[1] - i=2 + else: + start=1 + min_e=arr[0] + max_e=arr[0] - + i=start while(iarr[i+1]): min_e=min(min_e,arr[i+1])