Given two sorted arrays nums1 and nums2, return a new sorted array containing all elements from both.
Input
nums1: a sorted array of integers
nums2: a sorted array of integers
Output
A new sorted array of length nums1.length + nums2.length containing every element from both inputs.
Examples
Example 1
Inputnums1 = [1, 3, 5], nums2 = [2, 4, 6]
Output[1, 2, 3, 4, 5, 6]
Example 2
Inputnums1 = [], nums2 = []
Output[]
Constraints
Use two pointers walking nums1 and nums2 in parallel; append the smaller front element each step.
Runs in O(n + m) time.