Skip to content

Commit 7c2fd47

Browse files
committed
leetcode_twosum_firstproblem
1 parent 39a3046 commit 7c2fd47

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

leetcode_twosum.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def twoSum(nums, target):
2+
my_list=[ ]
3+
for i in range (0, len(nums)-1):
4+
for j in range(i+1,len(nums) ):
5+
sum= nums[i]+nums[j]
6+
if sum==target:
7+
my_list.extend([i, j])
8+
print(my_list)
9+
10+
target=6
11+
nums= [2,4,5,7,8]
12+
twoSum(nums,target)

0 commit comments

Comments
 (0)