mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Keep condition consistent
This commit is contained in:
parent
2b5c1b9d02
commit
68bb214bc0
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue