InsertSort by Java


  • 0
    Z

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


Log in to reply
 

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