Merge Two Sorted Arrays
ARRAY
SORTING
Problem
Given two sorted arrays arr1
and arr2
, return a single sorted array in non-decreasing order.
Examples:
mergeSortedArrays([1,2,3], [2,5,6]); // [1,2,2,3,5,6] mergeSortedArrays([1], []); // [1]
Time Complexity
The algorithm should have a time complexity of O(n1 + n2)
where n1
and n2
are the sizes of arr1
and arr2
respectively.
Loading...