What does grid[row][col] mean?
It is standard 2D array access notation. It retrieves the exact value located at the specified row (Y-axis) and column (X-axis) coordinate.
Verify This Answer
Cross-check this information using these trusted sources:
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
