Skip to content
Merged
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
20 changes: 20 additions & 0 deletions algorithms/math/two-sums
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Complexity = O(N*M)
Given an Array of Integers
return the index of the two numbers which their sum is equals
to the target

"""
def twoSum(nums, target):
i = 0
flag = False
for i in range(len(nums)):
if(flag):
break
for j in range(len(nums)):
if( i !=j ):
if(nums[i] + nums[j] == target):
print(str(i) + " " + str(j))
flag = True