From 4ad0c6ef9e79f5bc1d4217f723c781ca028ac556 Mon Sep 17 00:00:00 2001 From: Vaishnavi Gawale Date: Sun, 11 Jan 2026 23:40:54 -0500 Subject: [PATCH 1/2] Done Competitive-Coding-2 --- .DS_Store | Bin 0 -> 6148 bytes Problem1-2Sum.py | 17 +++++++++++++++++ Problem2-knapsack.py | 24 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .DS_Store create mode 100644 Problem1-2Sum.py create mode 100644 Problem2-knapsack.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..15055e9673e6289b17d13a08b391cb92ce5dad1d GIT binary patch literal 6148 zcmeHKO-sW-5Ph2#Y4L;N$>UzV6xv@9OMCDjh=Ny5n&JnQ7PX4tAwR_*h~25-NC_kawq$g0d_7%}4=hs`@CpAj$KQFx6zwhkg@7Z;e|1Y?{L`#fb) z{f(`Uh`~!WRX`O`1-4KD)@-rPu16hJ0aZX1SSujk2TK=B1C}1$r-OrQ0f=peopCO` zgm7%YG+^nGD>UP&L{BxL#W0@ExD9z}z|y0q!-VF;gq=<3P>kE1_qQ$`CiSSJDxeBf z6=?a(p49)z@BM$3q*tndD)6rqFzxZ>c*G-x+FCoD)LKiwp^Hgg>2Xcr#Fb*^N+~{~ aJ7e6+gqQ{_Ju*VmKLSn$9aMooRp1Bs&SXje literal 0 HcmV?d00001 diff --git a/Problem1-2Sum.py b/Problem1-2Sum.py new file mode 100644 index 00000000..65529304 --- /dev/null +++ b/Problem1-2Sum.py @@ -0,0 +1,17 @@ +''' Time Complexity : O(n) + Space Complexity : O(n) + Did this code successfully run on Leetcode : Yes + Any problem you faced while coding this : No + +''' +class Solution: + def twoSum(self, nums, target): + hashmap = {} + + for i in range(len(nums)): + diff = target - nums[i] + if diff in hashmap: + return [hashmap[diff], i] + hashmap[nums[i]] = i + + return [] \ No newline at end of file diff --git a/Problem2-knapsack.py b/Problem2-knapsack.py new file mode 100644 index 00000000..40867d7d --- /dev/null +++ b/Problem2-knapsack.py @@ -0,0 +1,24 @@ +''' Time Complexity : O(m * n) + Space Complexity : O(m * n) + Did this code successfully run on Leetcode : Yes + Any problem you faced while coding this : No + +''' + +def helper(weights, values, W): + n = len(weights) + dp = [[0] * (W + 1) for _ in range(n + 1)] + for i in range(1, n + 1): + for w in range(W + 1): + if weights[i - 1] <= w: + dp[i][w] = max( dp[i - 1][w], + values[i - 1] + dp[i - 1][w - weights[i - 1]]) + else: + dp[i][w] = dp[i - 1][w] + return dp[n][W] + + +values = [60, 100, 120] +weights= [10, 20, 30] +result = helper(weights,values,50) +print("Result = ", result) \ No newline at end of file From 887dc296e8f60a37acabf66ccc0bc521813f1bc5 Mon Sep 17 00:00:00 2001 From: Vaishnavi Gawale <39532048+vaishnavi2231@users.noreply.github.com> Date: Sun, 11 Jan 2026 23:43:37 -0500 Subject: [PATCH 2/2] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 15055e9673e6289b17d13a08b391cb92ce5dad1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO-sW-5Ph2#Y4L;N$>UzV6xv@9OMCDjh=Ny5n&JnQ7PX4tAwR_*h~25-NC_kawq$g0d_7%}4=hs`@CpAj$KQFx6zwhkg@7Z;e|1Y?{L`#fb) z{f(`Uh`~!WRX`O`1-4KD)@-rPu16hJ0aZX1SSujk2TK=B1C}1$r-OrQ0f=peopCO` zgm7%YG+^nGD>UP&L{BxL#W0@ExD9z}z|y0q!-VF;gq=<3P>kE1_qQ$`CiSSJDxeBf z6=?a(p49)z@BM$3q*tndD)6rqFzxZ>c*G-x+FCoD)LKiwp^Hgg>2Xcr#Fb*^N+~{~ aJ7e6+gqQ{_Ju*VmKLSn$9aMooRp1Bs&SXje