Java two line


  • 0
    class Solution {
        public void merge(int[] nums1, int m, int[] nums2, int n) {
            for (int k = m-- + n-- - 1; k >= 0; k--) {
                nums1[k] = n < 0 || (m >= 0 && nums1[m] > nums2[n]) ? nums1[m--] : nums2[n--];
            }
        }
    }

Log in to reply
 

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