Merge Sorted Array

Easy

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order. Merge them into a single array sorted in non-decreasing order and return it.

Example 1

mergeSorted()
Input
nums1 = [1,2,3], nums2 = [2,5,6]
Output
[1,2,2,3,5,6]

Example 2

mergeSorted()
Input
nums1 = [], nums2 = [1]
Output
[1]
Constraints
0 <= nums1.length, nums2.length <= 200
Both arrays are sorted in non-decreasing order.

Topics

ArraysTwo PointersSorting

Implement mergeSorted in the editor and return the answer — printing it is never graded.