Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removedProblem1.java
Empty file.
14 changes: 14 additions & 0 deletions Problem1.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
#Time Complexity : O(n)
#Space Complexity : O(n)
#Did this code successfully run on Leetcode :Yes

class Solution:
def twoSum(self, nums, target):
n = len(nums)

for i in range(n):
for j in range(i + 1, n):
if nums[i] + nums[j] == target:
return [i, j]

return [-1, -1]
Empty file removedProblem2.java
Empty file.
14 changes: 14 additions & 0 deletions Problem2.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
#Time Complexity : O(n*m)
#Space Complexity : O(n)
class Solution:
@staticmethod
def findMax(weights, profit, totalCapacity):
n = totalCapacity
m = len(weights)
dp = [0] * (n + 1)

for i in range(m):
for j in range(n, weights[i] - 1, -1):
dp[j] = max(dp[j], profit[i] + dp[j - weights[i]])

return dp[n]