GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.hackerrank.com — Connected Cells in a Grid | HackerRank We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies. Consider a matrix where each cell contains either a or a . Any cell containing a is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. In the following grid, all cells marked
If one or more filled cells are also connected, they form a region. Note that each cell in a region is connected to zero or more cells in the region but is not necessarily directly connected to all the other cells in the region. Given an matrix, find and print the number of cells in the largest region in the matrix. Note that there may be more than one region in the matrix. For example, there are two regions in the following matrix. The larger region at the top left contains cells. The smaller one at the bottom right contains .
Function Description Complete the connectedCell function in the editor below. connectedCell has the following parameter(s): Returns Input Format The first line contains an integer , the number of rows in the matrix. Constraints Sample Input Sample Output Explanation The diagram below depicts two regions of the matrix. Connected regions are filled with X or Y. Zeros are replaced with dots for clarity.
The larger region has cells, marked Cookie support is required to access HackerRankSeems like cookies are disabled on this browser, please enable them to open this website |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |