GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Mountain Man I am not getting wrong answer could you help me to figure what is wrong in in my code

import java.util.*;

class TestClass {
 public static void main(String args[] ) throws Exception {
     //Scanner
     Scanner sc = new Scanner(System.in);
     TestClass main = new TestClass();
     int n = sc.nextInt();
     int k = sc.nextInt();
     int totalEnergy = 9;
     
     
     int stone[][] = new int[k][n];
     
     for (int i = 0; i < k; i++) {
         //System.out.println("layer " + i);
         for (int j = 0; j <n ; j++) {
             stone[i][j] = sc.nextInt();
         }
     }
     sc.close();
     //End of reading inputs
     if(k<=5){
     boolean selectedLayer[] = new boolean[k];
     int selectPosition[] = new int[n];
     int i;
     for ( i = 0; i< n; i++) {
    selectPosition[i] = main.getMinOfArray(stone , i);
    totalEnergy += stone[selectPosition[i]][i];
     }
    
    
     }
     
     System.out.println(totalEnergy);
 }
 
 private int getMinOfArray(int [][] columnValues, int columnIndex) {
int indexOfStones = 0;
for (int i=0; i < columnValues.length-1; i++) {
if(columnValues[i][columnIndex] > columnValues[i][columnIndex]) {
indexOfStones = i;
}
}
return indexOfStones;
 }
}

 

asked Feb 19, 2017 by ganesh g
...