My Java Solution, ask for review


  • 0
    U
    public class Solution {
        public void merge(int[] nums1, int m, int[] nums2, int n) {
            int swap_des = m + n - 1;
            int p1 = m - 1;
            int p2 = n - 1;
            while (p1 >= 0 && p2 >= 0)
                nums1[swap_des--] = nums1[p1] > nums2[p2]? nums1[p1--]: nums2[p2--];
            while (p2 >= 0) nums1[swap_des--] = nums2[p2--];
        }
    }
    

Log in to reply
 

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