4-Line C# Solution


  • 0
    L
    public void Merge(int[] nums1, int m, int[] nums2, int n) {
        int i1 = m - 1, i2 = n - 1, i = m + n - 1;
        while(i2 >= 0)
            nums1[i--] = i1 < 0 ? nums2[i2--]
                                : nums2[i2] >= nums1[i1] ? nums2[i2--] : nums1[i1--];
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.