我有一个大数组。我有一些 Java 代码用于识别该大数组的子集/切片的起点和终点的索引。我需要从数组的选定子部分检索的唯一信息项是局部最大值和最小值的索引和值。我可以在指定范围内找到最大值和最小值的最快(且内存占用最少)的方法是什么?
这是我在代码方面需要的开始:
// Step One: declare new array and populate it
pts = new double[5000];
for (int i = 0; i < 5000; i++){ pts[i] = (value assigned by extraneous process);}
// Step Two: slice out section between indices 3600 and 3750
// what code do I write here?
// Step Three: find max value in the sliced section and return its index
// what code to I write here?