data_structures.arrays.merge_sorted =================================== .. py:module:: data_structures.arrays.merge_sorted Functions --------- .. autoapisummary:: data_structures.arrays.merge_sorted.merge_sorted_arrays Module Contents --------------- .. py:function:: merge_sorted_arrays(nums1: list[int], nums2: list[int]) -> list[int] Merge two sorted arrays into one sorted array. Args: nums1: The first sorted array. nums2: The second sorted array. Returns: A single merged and sorted array. Examples: >>> merge_sorted_arrays([1, 3, 5], [2, 4, 6]) [1, 2, 3, 4, 5, 6] >>> merge_sorted_arrays([1, 2], []) [1, 2] >>> merge_sorted_arrays([], [3, 4]) [3, 4] >>> merge_sorted_arrays([], []) [] >>> merge_sorted_arrays([0, 0], [0, 0]) [0, 0, 0, 0] >>> merge_sorted_arrays([-5, -3, -1], [-2, -2]) [-5, -3, -2, -2, -1] >>> merge_sorted_arrays(range(5), range(5)) [0, 0, 1, 1, 2, 2, 3, 3, 4, 4] >>> merge_sorted_arrays([1, -1], []) Traceback (most recent call last): ... ValueError: nums = [1, -1] is not sorted >>> merge_sorted_arrays([], [1, -1]) Traceback (most recent call last): ... ValueError: nums = [1, -1] is not sorted