I have a 2 dimensional array of strings and I would like to find the max of every 13 elements.
The array is array[String date][String price1][String price2].
I would like the max of price1 0-12, then price1 1-13, then price1 2-14, etc
{1,2,3,4,5,6,7,8,9,10,9,8,11,6,5,4,3,2,1}
the first list of 13 {1,2,3,4,5,6,7,8,9,10,9,8,7} would return 10
the second list of 13 {2,3,4,5,6,7,8,9,10,9,8,7,11} would return 11
the third list of 13 {3,4,5,6,7,8,9,10,9,8,7,11,6} would return 11
etc
edit
sorry that was a bit confusing, the array is a 2 dimensional array of strings, the first column being dates, and the second and third being doubles. I would like to find the max of the 2nd column and the min of the 3rd.
here is what i had gotten:
String str = "";
for(int ii = 1 ; ii < array.length ; ii++){
str = str+array[ii][2]+",";
if(ii==13){
str = Math.max(str.substring(0, str.lastIndexOf(',', str.lastIndexOf(',') - 1)));
System.out.println(str);
}
}
Here is my solution(If you are dealing with integer array).
BUT you are saying [String date][String price1][String price2] at first and
later you gave example :
the first list of 13 {1,2,3,4,5,6,7,8,9,10,9,8,7} would return 10 the second list of 13 {2,3,4,5,6,7,8,9,10,9,8,7,11} would return 11 the third list of 13 {3,4,5,6,7,8,9,10,9,8,7,11,6} would return 11 etc
Please be clear about that.
CODE:
Result: