Explain the time complexity of your solution for merging two sorted arrays.
Implement merge_sorted_arrays(nums1, nums2), which accepts two arrays of integers sorted in nondecreasing order and returns a new sorted array containing every value from both inputs. Explain why your solution has its stated time and space complexity.
def merge_sorted_arrays(nums1, nums2):