Skip to content

Instantly share code, notes, and snippets.

@abdellani
Last active October 24, 2019 16:33
Show Gist options
  • Save abdellani/d977b890896f0b142c96dc157d86d577 to your computer and use it in GitHub Desktop.
Save abdellani/d977b890896f0b142c96dc157d86d577 to your computer and use it in GitHub Desktop.
def find_pairs(array, k)
# write your code here
result=[]
array.each_with_index do |element,index|
result<<[element,k-element] if array[index+1..-1].include?(k-element)
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment