Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 467 Bytes

merging_sorted_integer_arrays_without_duplicates.md

File metadata and controls

19 lines (16 loc) · 467 Bytes

Description

Write a function that merges two sorted arrays into a single one. The arrays only contain integers. Also, the final outcome must be sorted and not have any duplicate.

My Solution

def merge_arrays(a, b)
  (a + b).uniq.sort
end

Better/Alternative solution from Codewars

def merge_arrays(a, b)
  (a | b).sort
end