public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int len1 = nums1.length, len2 = nums2.length;
        if(len1 == 0 && len2 == 0)  return 0;
        Arrays.sort(nums1);
        Arrays.sort(nums2);
        int i=0, j=0, k=0, len3 = len1 + len2;
        int[] temp = new int[len3];
        for(k=0; k < len1 + len2; k++){
            if(i < len1 && j < len2){
                if(nums1[i] < nums2[j])  {temp[k] = nums1[i]; i++;}
                else {temp[k] = nums2[j]; j++;}
            }else{
                if(i < len1) {temp[k] = nums1[i]; i++;}
                if(j < len2) {temp[k] = nums2[j]; j++;}
            }
        }
        return len3%2 == 0? (temp[len3/2 -1] + temp[len3/2])/2.0 : temp[len3/2];
    }