diff --git a/algorithms/math/two-sums b/algorithms/math/two-sums new file mode 100644 index 00000000..f10f569b --- /dev/null +++ b/algorithms/math/two-sums @@ -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 + +