public void findMax(array) {
int count = 0;
int max = INT_MIN;
int prev_ind = 0;
for (int i=0; i<array.length; i++) {
if (array[i] > max) {
intv[count] = i-prev_ind
prev_ind = i
count++;
max = array[i];
}
}
}
代码取自this question。最高评级的答案告诉变量“count”的预期值将是第n个谐波数。我的问题是:
intv [k-1]的期望值是什么,即(k-1)-th和第k(右包含)赋值之间的间隔长度是什么?