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.