当前位置:网站首页>Maximum area of islands searched
Maximum area of islands searched
2022-06-30 14:40:00 【Douglas_ LT】
A daily topic ing, Today is a day medium topic 695. Max Area of Island
class Solution {
public:
int maxAreaOfIsland(vector<vector<int>>& grid) {
int ret=0;
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[i].size();j++){
if(grid[i][j]==1)
ret=max(ret,dfs(grid,i,j));
}
}
return ret;
}
int dfs(vector<vector<int>>& grid,int i,int j){
if(i<0||j<0||i>=grid.size()||j>=grid[i].size()||grid[i][j]==0){
return 0;
}
grid[i][j]=0;// Avoid double counting
int num=1;
num=num+dfs(grid,i+1,j);
num=num+dfs(grid,i,j+1);
num=num+dfs(grid,i-1,j);
num=num+dfs(grid,i,j-1);
return num;
}
};
边栏推荐
- Pit used by go language array type
- [buuctf] [actf2020 freshman competition]include
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs
- Use of laravel repository mode
- DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
- Solution cannot use a scalar value as an array
- DefCamp Capture the Flag (D-CTF) 2021-22 web
- Knowledge learned from the water resources institute project
- Geoffreyhinton: my 50 years of in-depth study and Research on mental skills
猜你喜欢

Thinkphp5 log file contains trick

Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package

Computer screenshot how to cut the mouse in

ThinkPHP show method parameter controllable command execution
![[geek challenge 2019] PHP problem solving record](/img/bf/038082e8ee1c91eaf6e35add39f760.jpg)
[geek challenge 2019] PHP problem solving record

Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~

【BUUCTF】 Have Fun

Knowledge learned from the water resources institute project

Component communication mode

Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit
随机推荐
Ctfshow getting started with the web (ThinkPHP topic)
KnightCTF WEB
2021 geek challenge Web
DiceCTF - knock-knock
Upgrade composer self update
ctfshow nodejs
Summary of use of laravel DCAT admin
LIS error: this configuration section cannot be used in this path
Implement a long-click list pop-up box on apiccloud
The first three passes of sqli Labs
Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit
Thinkphp5 log file contains trick
The difference between settimeout() and setinterval()
go channel && select
Greedy two-dimensional array sorting
Go language for loop multivariable use
Laravel upload error
數據恢複軟件EasyRecovery15下載
V3 03_ Getting started
Go sync. WaitGroup