Gold Mine Problem - GeeksforGeeks

Hello All,
Can somebody explain me what’s the use of creating goldTable[m][n] instead of goldTable[n][m]? I know it has something to do with information given in the question that “you are on the first column but could be on any row” .On the similar note can you also explain why did for loop iterates over column instead of row?? Also if suppose I follow the code why at line 36 it is goldTable[row][col] instead of goldTable[col][row]?
how can i keep the goldTable[n][m] and iterate row wise ?

Any help would be highly appreciated !!

1 Like

The loop iterates in a row major order. And variables ‘m’ and ‘n’ are used in their usual lexicographical meaning; ‘m’ for rows, ‘n’ for columns.