The initial solution comes to mind which obviously could be improved in performance purposes having more time
def two_sum(array, target)
array.each_with_index do |item, i|
(i + 1).upto(array.size - 1) do |j|
return [i, j] if item + array[j] == target
end
end
nil
end
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby
The initial solution comes to mind which obviously could be improved in performance purposes having more time