This content is archived!

For the 2018-2019 school year, we have switched to using the WLMOJ judge for all MCPT related content. This is an archive of our old website and will not be updated.


The declaration and use of a multidimensional array is very similar to that of a single dimension array.

int[][] grid = new int[N][M];
int[][][] cube = new int[X][Y][Z];

grid[0][1] = cube[0][0][0];
grid[0].length; // M
cube[0].length; // Y

As more dimensions are added, the memory required grows exponentially.


Time complexity

Access: \mathcal{O}(1)

Space complexity

\mathcal{O}(S_0 \times S_1 \times S_2 \times \dots \times S_k), where S_i is the size of the i^\text{th} dimension.