首页 > TAG信息列表 > grid1
LeetCode 1905. Count Sub Islands
原题链接在这里:https://leetcode.com/problems/count-sub-islands/ 题目: You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally2022-1-12DFSday5
题1: 695. 岛屿的最大面积 给你一个大小为 m x n 的二进制矩阵 grid 。 岛屿 是由一些相邻的 1 (代表土地) 构成的组合,这里的「相邻」要求两个 1 必须在 水平或者竖直的四个方向上 相邻。你可以假设 grid 的四个边缘都被 0(代表水)包围着。 岛屿的面积是岛上值为1905. 统计子岛屿
遍历grid2,如果在遍历一个岛屿的过程中没有超过相应的grid1的1的范围,说明遍历到了一个子岛屿,否则不是子岛屿 int st[510][510]; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int valid; class Solution { public: void dfs(int x, int y, int row, int col, vector<1905. Count Sub Islands
You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are