Skip to content

Commit

Permalink
Create easyproblems
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetsinha authored Apr 6, 2022
0 parents commit 376a2bc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions easyproblems
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Brute force
The brute force approach is simple. Loop through each element xx and find if there is another value that equals to target - xtarget−x.

class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[j] == target - nums[i]:
return [i, j]


2)

0 comments on commit 376a2bc

Please sign in to comment.