Preview:
class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        int p = m-1, q = n-1, ind = nums1.size()-1;
        while(p>=0 && q>=0) {
            if(nums2[q] > nums1[p]) {
                nums1[ind--] = nums2[q];
                q--;
            }
            else    {
                nums1[ind--] = nums1[p];
                p--;
            }
        }
        while(q >= 0)    {
            nums1[ind--] = nums2[q--];
        }
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter