Keep condition consistent

This commit is contained in:
Vitor Oliveira 2021-03-11 22:01:02 -08:00
parent 2b5c1b9d02
commit 68bb214bc0

View file

@ -67,8 +67,8 @@ print(two_sum([3, 3], 6))
# Time Complexity: O(N^2), where N is the length of the array
#
def two_sum(nums, target)
nums.count.times do |i|
target_difference = target - nums[i]
nums.each_with_index do |num, i|
target_difference = target - num
nums.each_with_index do |num, j|
if i != j && num == target_difference