two sum in ruby(taking time more to run) easy way??
  def two_sum(nums, target)
    length = nums.length
    for i in 0..length
      j = i+ 1
      for a in j..length
        if j < length
          if nums[i] + nums[a] == target
            return [i, a]
          end
        end
        j+=1
      end
    end
  end
Comments (1)