Skip to content

Instantly share code, notes, and snippets.

@dustMason
Created July 28, 2017 04:22
Show Gist options
  • Save dustMason/b2ffbe695c193a786f2f79616ab2e366 to your computer and use it in GitHub Desktop.
Save dustMason/b2ffbe695c193a786f2f79616ab2e366 to your computer and use it in GitHub Desktop.
def find_median_sorted arr1, arr2
joined = (arr1 + arr2).sort
if joined.size % 2 == 0
return joined[(joined.size/2)-1..(joined.size/2)].reduce(&:+) / 2.0
else
return joined[joined.size/2]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment