https://leetcode.com/problems/merge-sorted-array/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        int r1 = m - 1, r2 = n - 1;
        int idx = m + n - 1;
        while (idx >= 0) {
            int n1 = r1 >= 0 ? nums1[r1] : -INT_MAX;
            int n2 = r2 >= 0 ? nums2[r2] : -INT_MAX;
            nums1[idx] = max(n1, n2);
            if (n1 >= n2) {
                r1 -= 1;
            } else {
                r2 -= 1;
            }
            idx -= 1;
        }
    }
};

Time Complexity: O(n)
Space: O(1)

從大的開始排就可以在 inplace 處理掉這題