A matrix (2D array) is a grid of numbers with R rows and C columns. Where a plain
array needs one index, a grid needs two: g[i][j] is the value at row i, column j
(both zero-based). Row index first, column index second — keep that order straight and half the
bugs vanish.
The input shape is the counts then the grid: R, then C, then R lines of C numbers. The starter
reads it and hands your solve the dimensions and the grid.
def solve(r, c, g):
return g[0][0] # top-left corner: row 0, column 0
static long solve(int r, int c, long[][] g) {
return g[0][0];
}
Valid rows run 0..r-1 and valid columns 0..c-1. The bottom-right corner is
g[r-1][c-1]. Picture the grid as a spreadsheet: you locate a cell by its row and its column,
and that pair of indices is the only new idea the whole module rests on.