#include <leetcode.h>
◆ maxAreaOfIsland()
int leetcode::max_area_of_island::Solution::maxAreaOfIsland |
( |
vector< vector< int > > & |
grid | ) |
|
|
static |
在文件 leetcode.cpp 第 4227 行定义.
4228 const int m = grid.size();
4229 const int n = grid[0].size();
4232 for(
int i = 0; i < m; i++) {
4233 for(
int j = 0; j < n; j++) {
4234 if(grid[i][j] == 1) {
4235 const pair<int, int> p = make_pair(i, j);
4236 ans = max(ans, uf.get_size(p));
4237 pair<int, int> siblings[4] = {
4238 make_pair(i + 1, j),
4239 make_pair(i - 1, j),
4240 make_pair(i, j + 1),
4241 make_pair(i, j - 1),
4243 for(
const auto sibling: siblings) {
4244 if(uf.contains(sibling) && grid[sibling.first][sibling.second] == 1 && !uf.same(p, sibling)) {
4245 uf.merge(p, sibling);
4246 ans = max(ans, uf.get_size(p));
被这些函数引用 leetcode::max_area_of_island::TEST().
该类的文档由以下文件生成: