We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 495819a commit 94768a1Copy full SHA for 94768a1
neetcodeio/algostructybeginners/Lv1-Arrays/twosum_bruteforce.py
@@ -0,0 +1,13 @@
1
+class Solution:
2
+ def twoSum(self, nums: list[int], target: int) -> list[int]:
3
+ for i in range(len(nums)):
4
+ for j in range(i, len(nums)):
5
+ if nums[i] + nums[j] == target and i != j:
6
+ return [i, j]
7
+ return [-1, -1]
8
+
9
10
+arr = [3, 4, 5, 6]
11
+target = 7
12
+sol = Solution()
13
+assert sol.twoSum(arr, target) == [0, 1]
0 commit comments