Episode 16 – Two Sum Part 2

The Code Snippets Podcast
The Code Snippets Podcast
Episode 16 - Two Sum Part 2
/

Today I talk about two sum problem

def two_sum(num, target)
  (0..num.length-1).each do |n|
    pointer=n+1
    (pointer..num.length-1).each do |j|
      if num[n] +num[j]== target
        return [n,j]
      end
    end
  end
end