Click4Ai

11.

Easy

Write a function merge_arrays(arr1, arr2) that merges two sorted arrays into a single sorted array without using built-in sort.

Example:

Input: arr1 = [1, 3, 5], arr2 = [2, 4, 6]

Output: [1, 2, 3, 4, 5, 6]

Constraints:

  • Both input arrays are sorted in ascending order
  • 0 <= len(arr1), len(arr2) <= 500
  • Return a new sorted list
  • Test Cases

    Test Case 1
    Input: [1, 3, 5], [2, 4, 6]
    Expected: [1, 2, 3, 4, 5, 6]
    Test Case 2
    Input: [1, 2, 3], [4, 5, 6]
    Expected: [1, 2, 3, 4, 5, 6]
    Test Case 3
    Input: [], [1, 2, 3]
    Expected: [1, 2, 3]
    + 2 hidden test cases