It is standard 2D array access notation. It retrieves the exact value located at the specified row (Y-axis) and column (X-axis) coordinate.
Printing 2D Grids and Matrices Using Nested Loops
What does grid[row][col] mean?
The answer
More FAQs in Printing 2D Grids and Matrices Using Nested Loops
A matrix is two-dimensional. You need an outer loop to traverse vertically through the rows, and an inner loop to traverse horizontally through the columns.
If N is the width of a square matrix, traversing the N x N grid takes O(N^2) operations. However, relative to the total number of items (M), the traversal is O(M) linear time.
Simply invert the loops. Make the outer loop iterate over the columns (0 to width), and the inner loop iterate over the rows (0 to height).
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.