code13专题

Code13 数组中左边大于2倍右边数的总对数

数组 [6,4,2,1] 其中(6,2)(6,1)(4,1)这3个组合是满足左边大于右边数的两倍 核心代码块,建立在归并排序的基础上 int ans = 0;int windowR = M+1;for (int j = L;j<=M;j++){while (windowR <= R && arr[j] > (arr[windowR]*2)){windowR ++;}ans += window