Merge Sorted Array

You are given two non-decreasing integer arrays and two counts m and n. The first m values of nums1 are valid, and nums1 has total length m + n, so the trailing n slots are spare capacity rather than input values. Merge the m + n valid values into nums1 itself so that the buffer holds the sorted result, and return an array containing those same m + n values in sorted order. The optimal solution writes from the back of nums1, so no valid element is overwritten before it has been compared.

Examples
Input: [[1,2,3,0,0,0],3,[2,5,6],3]
Output: [1,2,2,3,5,6]
Hints

Merge Sorted Array

You are given two non-decreasing integer arrays and two counts m and n. The first m values of nums1 are valid, and nums1 has total length m + n, so the trailing n slots are spare capacity rather than input values. Merge the m + n valid values into nums1 itself so that the buffer holds the sorted result, and return an array containing those same m + n values in sorted order. The optimal solution writes from the back of nums1, so no valid element is overwritten before it has been compared.