i'm writing a function that retrieves the maximum of each row in a 2d array, and returns a 1d array, where each index is relative to the 2d array's column row index.
For example, if I have an 2d array:
{1,2,3}
{4,5,6}
{7,8,9}
it should return an array of
{3,6,9}
here is my code so far:
double[] rowMaxes(double[][] nums) {
double [] count = new double [nums.length];
for(int i = 0; i < count.length; i++){
for(int x = 0; x < nums[0].length; x++){
for(int n = 0; n < nums.length; n++){
if(nums[x][n] > count[i]){
count[i] = nums[x][n];
}
}
}
}
return count;
}