Example 1: [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,1,0,0,1,0,1,0,0], [0,1,0,0,1,1,0,0,1,1,1,0,0], [0,0,0,0,0,0,0,0,0,0,1,0,0],...


Please answer the question in the screenshot. Please use the starter code.


Example 1:<br>[[0,0,1,0,0,0,0,1,0,0,0,0,0],<br>[0,0,0,0,0,0,0,1,1,1,0,0,0],<br>[0,1,1,0,1,0,0,0,0,0,0,0,0],<br>[0,1,0,0,1,1,0,0,1,0,1,0,0],<br>[0,1,0,0,1,1,0,0,1,1,1,0,0],<br>[0,0,0,0,0,0,0,0,0,0,1,0,0],<br>[0,0,0,0,0,0,0,1,1,1,0,0,0],<br>[0,0,0,0,0,0,0,1,1,0,0,0,0]]<br>Practice 1<br>Given a non-empty 2D array grid of O's<br>and 1's, an island is a group of 1's<br>(representing land) connected<br>4-directionally (horizontal or vertical.)<br>You may assume all four edges of the<br>grid are surrounded by water.<br>Given the above grid, return 6. Note the answer is not 11,<br>because the island must be connected 4-directionally.<br>Find the maximum area of an island in<br>the given 2D array. (If there is no<br>island, the maximum area is 0.)<br>Example 2:<br>[[0,0,0,0,0,0,0,0]]<br>Given the above grid, return 0.<br>class Graph {<br>public int maxAreaofIsland(int[][] grid) {<br>}<br>}<br>

Extracted text: Example 1: [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,1,0,0,1,0,1,0,0], [0,1,0,0,1,1,0,0,1,1,1,0,0], [0,0,0,0,0,0,0,0,0,0,1,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,1,1,0,0,0,0]] Practice 1 Given a non-empty 2D array grid of O's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. Given the above grid, return 6. Note the answer is not 11, because the island must be connected 4-directionally. Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is 0.) Example 2: [[0,0,0,0,0,0,0,0]] Given the above grid, return 0. class Graph { public int maxAreaofIsland(int[][] grid) { } }

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here