Answers for "find median numbe in array ruby"

0

ruby median find

def median(array)
  return nil if array.empty?
  
  sorted = array.sort
  len = sorted.length 
  (sorted[(len - 1) / 2] + sorted[len / 2]) / 2
end
Posted by: Guest on March-15-2021

Browse Popular Code Answers by Language