当前位置: 首页 > news >正文

现在c 做网站用什么软件徐州市中宇建设工程有限公司网站

现在c 做网站用什么软件,徐州市中宇建设工程有限公司网站,济南网站建设直播,做网站美工未来规划200. 岛屿数量 200. 岛屿数量时间:O(mn);空间:O(min(m, n)),队列最大入队个数,可以想象从左上到右下,第一次入队1个,第二次出队1,入队2,第三次出队2,入队3……

200. 岛屿数量

  • 200. 岛屿数量
  • 时间:O(mn);空间:O(min(m, n)),队列最大入队个数,可以想象从左上到右下,第一次入队1个,第二次出队1,入队2,第三次出队2,入队3…
class Solution {
public:int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};  // 右,下,左,上int count = 0;int row;int column;void bfs(vector<vector<char>>& grid, int x, int y){queue<pair<int, int>>q;q.push({x, y});while(!q.empty()){auto t = q.front();q.pop();for(int i = 0; i < 4; i++){int new_x = t.first + dir[i][0], new_y = t.second + dir[i][1];if(new_x < 0 || new_x >= row || new_y < 0 || new_y >= column){continue;}if(grid[new_x][new_y] != '1'){continue;}grid[new_x][new_y] = '0';  // 访问q.push({new_x, new_y});}}}int numIslands(vector<vector<char>>& grid) {// bfsrow = grid.size(), column = grid[0].size();for(int i = 0; i < row; i++){for(int j = 0; j < column; j++){if(grid[i][j] == '1'){bfs(grid, i, j);++count;}}}return count;}
};

695. 岛屿的最大面积

  • 695. 岛屿的最大面积
  • 同上,bfs
class Solution {
public:int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};  // 右,下,左,上int ret = 0;int row;int column;int bfs(vector<vector<int>>& grid, int x, int y){grid[x][y] = 0;queue<pair<int, int>>q;q.push({x, y});int square = 1;while(!q.empty()){auto t = q.front();q.pop();for(int i = 0; i < 4; i++){int new_x = t.first + dir[i][0], new_y = t.second + dir[i][1];if(new_x < 0 || new_x >= row || new_y < 0 || new_y >= column){continue;}if(grid[new_x][new_y] != 1){continue;}grid[new_x][new_y] = 0;  // 访问++square;q.push({new_x, new_y});}}return square;}int maxAreaOfIsland(vector<vector<int>>& grid) {// bfsrow = grid.size(), column = grid[0].size();for(int i = 0; i < row; i++){for(int j = 0; j < column; j++){if(grid[i][j] == 1){int temp = bfs(grid, i, j);ret = max(ret, temp);}}}return ret;}
};

547. 省份数量

  • 547. 省份数量
  • 思路:修改bfs的访问
class Solution {
public:int count = 0;int row;int column;void bfs(vector<vector<int>>& grid, int x, int y){grid[x][y] = grid[y][x] = 0;queue<pair<int, int>>q;q.push({x, y});while(!q.empty()){auto t = q.front();q.pop();int new_x = t.first;for(int i = 0; i < column; i++){if(grid[new_x][i] == 0){continue;}grid[new_x][i] = grid[i][new_x] = 0;  // 访问q.push({i, new_x});}}}int findCircleNum(vector<vector<int>>& isConnected) {// bfsrow = isConnected.size(), column = isConnected[0].size();for(int i = 0; i < row; i++){for(int j = 0; j < column; j++){if(isConnected[i][j] == 1){bfs(isConnected, i, j);++count;}}}return count;}
};
http://www.yayakq.cn/news/213776/

相关文章:

  • 潍坊网站关键词推广桂阳网站开发
  • 网站维护中模版汕头澄海地图
  • 极速网站建设哪家好做酒业网站的要求
  • 网站图片上传不上去是什么情况服装网站策划书
  • 网站建设图片logo一个内部网站如何做外网映射
  • 网站关键词搜不到哈尔滨信息网58同城
  • 如何开网站详细步骤图济南英文网站建设
  • 网站备案有什么坏处wordpress小工具打不开
  • 品牌网站建设9小蝌蚪9为wordpress创建一个ftp
  • 想建立什么网站吗好看的wordpress图片主题
  • 免费.网站最新域名行政机关网站建设
  • 如何免费注册网站平台千锋培训学费多少钱
  • 做写手一般上什么网站好网站收录后怎么做排名
  • asp在网站制作中的作用软件开发工具名词解释
  • 说明怎样做才能通过互联网访问你制作的网站微网站 无锡
  • 如果让你建设一个网站做网站如何赢利的
  • html论坛网站模板下载网站头部 标签
  • 改网站描述组建做网站的团队
  • 去菲律宾做it网站开发哈尔滨ui设计培训学校
  • wordpress 美容主题找seo外包公司需要注意什么
  • 大沥做网站打造对外宣传工作平台网站建设
  • 伪原创嵌入网站沈阳关键词优化电话
  • 网站 工信部备案 收回微信小程序制作教学
  • 网站建设 呢咕云视频创作用什么软件
  • 做网站阜阳html网站模板
  • 学院网站制度建设做网站预算表
  • 南宁网站关键词推广个人soho要怎么做企业网站
  • 最新的购物网站 开企业建设网站需要什么资料
  • 常州网站建设技术托管购物网站开发毕业设计开题报告
  • 在哪个网站做流动补胎的广告好网站建设必知