Episode17 – Big O Notation

The Code Snippets Podcast
The Code Snippets Podcast
Episode17 - Big O Notation
/

This time i try to explain what Big O Notation is.

YouTube video explained it better

def two_sum(nums, target)

  checked = {}

  nums.each_with_index do |value, i|
      
      diff = target - value

      if checked[diff]
        return [checked[diff],i]
      else
          checked[value] = i
      end
  
  end

end