8.1.5 Manipulating 2d Arrays |work| Official
Login




Lost Password?

Register

Login Login by E-Mail Register
Premium Link Generator - All in One Cloud-Downloading

8.1.5 Manipulating 2d Arrays |work| Official

Notice the inner loop condition. Rows can technically be different lengths (a "jagged" array). It is best practice to check the length of the specific row you are currently iterating over ( grid[r].length ) rather than assuming all rows are the same size.

// Check the neighbor above (r-1) if (r - 1 >= 0) // Safe to access grid[r-1][c] 8.1.5 manipulating 2d arrays

Find the sum of all numbers in the grid. Notice the inner loop condition

This is easy because rows are stored contiguously. You just need one loop. 8.1.5 manipulating 2d arrays