From 6fac1126a9277eb72ed6d3a2a6b68a1a77762c2a Mon Sep 17 00:00:00 2001 From: Satish Mallikarjun Paraddi Date: Sun, 13 Sep 2026 17:12:12 -0400 Subject: [PATCH 1/2] Create Problem_1.py --- Problem_1.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Problem_1.py diff --git a/Problem_1.py b/Problem_1.py new file mode 100644 index 00000000..66d7dea4 --- /dev/null +++ b/Problem_1.py @@ -0,0 +1,20 @@ +#Time Complexity : O(2n) +#Space Complexity : O(1) +#Did this code successfully run on Leetcode :Yes +class Solution: + def findDisappearedNumbers(self, nums): + n = len(nums) + + for i in range(n): + j = abs(nums[i]) - 1 + if nums[j] > 0: + nums[j] *= -1 + + result = [] + for i in range(n): + if nums[i] > 0: + result.append(i + 1) + + return result + + From 42d611bad059819236195c0c47a2725e5f933d1b Mon Sep 17 00:00:00 2001 From: Satish Mallikarjun Paraddi Date: Sun, 13 Sep 2026 17:20:39 -0400 Subject: [PATCH 2/2] Complete problem_2.py --- Problem_2.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Problem_2.py diff --git a/Problem_2.py b/Problem_2.py new file mode 100644 index 00000000..e6eac591 --- /dev/null +++ b/Problem_2.py @@ -0,0 +1,31 @@ +#Time Complexity : O(m*n) +#Space Complexity : O(1) +#Did this code successfully run on Leetcode :Yes +class Solution: + def gameOfLife(self, board): + dir = [(-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)] + m, n = len(board), len(board[0]) + + def getCount(i, j): + count = 0 + for dx, dy in dir: + r, c = i + dx, j + dy + if 0 <= r < m and 0 <= c < n: + if board[r][c] == 1 or board[r][c] == 2: + count += 1 + return count + + for i in range(m): + for j in range(n): + cnt = getCount(i, j) + if board[i][j] == 0 and cnt == 3: + board[i][j] = 3 + elif board[i][j] == 1 and (cnt < 2 or cnt > 3): + board[i][j] = 2 + + for i in range(m): + for j in range(n): + if board[i][j] == 2: + board[i][j] = 0 + elif board[i][j] == 3: + board[i][j] = 1