# Accenture Coding Question | Maximum Sum of Column and Row | CodeWindow

#### Solution in JAVA 3:

``````public class CodeWindow {
public static void main(String[] args) {
int input1=3;
int input2=3;
int [] input3={3,6,9,1,4,7,2,8,9};
int ans= max( input1,input2,input3);
System.out.println(ans);
}

private static int max(int input1, int input2, int[] input3) {
int rows = input1;
int cols = input2;
int sumRow, sumCol;
int [] [] a= new int[input1][input2];
int count=0;

for(int i=0;i<input1;i++)

{
for(int j=0;j<input2;j++)
{
if(count==input3.length) break;
a[i][j]=input3[count];
count++;
}
}

int maxRow = Integer.MIN_VALUE;
for(int i = 0; i < rows; i++){
sumRow = 0;
for(int j = 0; j < cols; j++){
sumRow = sumRow + a[i][j];
}
maxRow=Math.max(maxRow,sumRow);
}

int maxCol=Integer.MIN_VALUE;

for(int i = 0; i < cols; i++){
sumCol = 0;
for(int j = 0; j < rows; j++){
sumCol = sumCol + a[j][i];
}
maxCol=Math.max(maxCol,sumCol);
}

return maxCol+maxRow;
}

}``````

Contributed by: Akshay Pokharkar