为什么我相同的思路,java实现,只通过了50% import java.util.*; public class Solution { public int InversePairs(int [] array) { if(array==null||array.length==0) return 0; int len = array.length; int ans=mergesort(array,0,len); return ans%1000000007; } int mergesort(int[] array,int begin,int end){ if(begin==end-1) return 0; int mid = ((begin+end)/2); int left = mergesort(array,begin,mid); int right = mergesort(array,mid,end); int merge_count = merge(array,begin,mid,end); return (left+right+merge_count); } int merge(int[] array,int begin,int mid,int end){ int i=begin; int j=mid; int count = 0; List<integer> list = new ArrayList<integer>(); while(i</integer></integer>
点赞

相关推荐

牛客网
牛客企业服务