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

滨州 网站开发阿里seo排名优化软件

滨州 网站开发,阿里seo排名优化软件,用php做的大型网站有哪些,网站备案好麻烦leetcode 130. 被围绕的区域 题目链接:被围绕的区域 步骤一:深搜或者广搜将地图周边的’O’全部改成’A’ 步骤二:遍历地图,将’O’全部改成’X’,将’A’改回’O’ class Solution { private:int dir[4][2] {-1, 0…

leetcode 130. 被围绕的区域

题目链接:被围绕的区域
步骤一:深搜或者广搜将地图周边的’O’全部改成’A’
步骤二:遍历地图,将’O’全部改成’X’,将’A’改回’O’

class Solution {
private:int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1}; // 保存四个方向void dfs(vector<vector<char>>& board, int x, int y) {board[x][y] = 'A';for (int i = 0; i < 4; i++) { // 向四个方向遍历int nextx = x + dir[i][0];int nexty = y + dir[i][1];// 超过边界if (nextx < 0 || nextx >= board.size() || nexty < 0 || nexty >= board[0].size()) continue;//不符合条件,不继续遍历if (board[nextx][nexty] == 'X' || board[nextx][nexty] == 'A') continue;dfs (board, nextx, nexty);}return;}public:void solve(vector<vector<char>>& board) {int n = board.size(), m = board[0].size(); // 步骤一:// 从左侧边,和右侧边向中间遍历for (int i = 0; i < n; i++) {if (board[i][0] == 'O') dfs(board, i, 0);if (board[i][m - 1] == 'O') dfs(board, i, m - 1);}// 从上边和下边向中间遍历for (int j = 0; j < m; j++) {if (board[0][j] == 'O') dfs(board, 0, j);if (board[n - 1][j] == 'O') dfs(board, n - 1, j);}// 步骤二:for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (board[i][j] == 'O') board[i][j] = 'X';if (board[i][j] == 'A') board[i][j] = 'O';}}}
};

leetcode 417. 太平洋大西洋水流问题

题目链接:太平洋大西洋水流问题
思路:从太平洋边上的节点 逆流而上,将遍历过的节点都标记上。 从大西洋的边上节点 逆流而长,将遍历过的节点也标记上。 然后两方都标记过的节点就是既可以流太平洋也可以流大西洋的节点

class Solution {
private:int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1}; // 保存四个方向// 从低向高遍历,注意这里visited是引用,即可以改变传入的pacific和atlantic的值void dfs(vector<vector<int>>& heights, vector<vector<bool>>& visited, int x, int y) {if (visited[x][y]) return;visited[x][y] = true;for (int i = 0; i < 4; i++) { // 向四个方向遍历int nextx = x + dir[i][0];int nexty = y + dir[i][1];// 超过边界if (nextx < 0 || nextx >= heights.size() || nexty < 0 || nexty >= heights[0].size()) continue;// 高度不合适,注意这里是从低向高判断if (heights[x][y] > heights[nextx][nexty]) continue;dfs (heights, visited, nextx, nexty);}return;}
public:vector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {vector<vector<int>> result;int n = heights.size();int m = heights[0].size(); // 这里不用担心空指针,题目要求说了长宽都大于1// 记录从太平洋边出发,可以遍历的节点vector<vector<bool>> pacific = vector<vector<bool>>(n, vector<bool>(m, false));// 记录从大西洋出发,可以遍历的节点vector<vector<bool>> atlantic = vector<vector<bool>>(n, vector<bool>(m, false));// 从最上最下行的节点出发,向高处遍历for (int i = 0; i < n; i++) {dfs (heights, pacific, i, 0); // 遍历最左列,接触太平洋 dfs (heights, atlantic, i, m - 1); // 遍历最右列,接触大西 }// 从最左最右列的节点出发,向高处遍历for (int j = 0; j < m; j++) {dfs (heights, pacific, 0, j); // 遍历最上行,接触太平洋dfs (heights, atlantic, n - 1, j); // 遍历最下行,接触大西洋}for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {// 如果这个节点,从太平洋和大西洋出发都遍历过,就是结果if (pacific[i][j] && atlantic[i][j]) result.push_back({i, j});}}return result;}
};

时间复杂度: O(n * m)
空间复杂度:O(n * m)

leetcode 827. 最大人工岛

题目链接:最大人工岛
第一步:一次遍历地图,得出各个岛屿的面积,并做编号记录。可以使用map记录,key为岛屿编号,value为岛屿面积
第二步:遍历地图,遍历0的方格(因为要将0变成1),并统计该1(由0变成的1)周边岛屿面积,将其相邻面积相加在一起,遍历所有0之后,就可以得出选一个0变成1之后的最大面积

lass Solution {
private:int count;int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1}; // 四个方向void dfs(vector<vector<int>>& grid, vector<vector<bool>>& visited, int x, int y, int mark) {if (visited[x][y] || grid[x][y] == 0) return; // 终止条件:访问过的节点或者遇到海水visited[x][y] = true; //标记访问过grid[x][y] = mark; //给陆地标记新标签count++;for (int i = 0; i < 4; i++) {int nextx = x + dir[i][0];int nexty = y + dir[i][1];if (nextx < 0 || nextx >= grid.size() || nexty < 0 || nexty >= grid[0].size()) continue;  //越界了,直接跳过dfs(grid, visited, nextx, nexty, mark);}}
public:int largestIsland(vector<vector<int>>& grid) {int n = grid.size(), m = grid[0].size();vector<vector<bool>> visited = vector<vector<bool>>(n, vector<bool>(m, false)); // 标记访问过的点unordered_map<int ,int> gridNum;int mark = 2; // 记录每个岛屿的编号bool isAllGrid = true; // 标记是否整个地图都是陆地for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (grid[i][j] == 0) isAllGrid = false;if (!visited[i][j] && grid[i][j] == 1) {count = 0;dfs(grid, visited, i, j, mark); // 将与其链接的陆地都标记上 truegridNum[mark] = count; // 记录每一个岛屿的面积mark++; // 记录下一个岛屿编号}}}if (isAllGrid) return n * m; // 如果都是陆地,返回全面积// 以下逻辑是根据添加陆地的位置,计算周边岛屿面积之和int result = 0; // 记录最后结果unordered_set<int> visitedGrid; // 标记访问过的岛屿for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {int count = 1; // 记录连接之后的岛屿数量visitedGrid.clear(); // 每次使用时,清空if (grid[i][j] == 0) {for (int k = 0; k < 4; k++) {int neari = i + dir[k][1]; // 计算相邻坐标int nearj = j + dir[k][0];if (neari < 0 || neari >= grid.size() || nearj < 0 || nearj >= grid[0].size()) continue;if (visitedGrid.count(grid[neari][nearj])) continue; // 添加过的岛屿不要重复添加// 把相邻四面的岛屿数量加起来count += gridNum[grid[neari][nearj]];visitedGrid.insert(grid[neari][nearj]); // 标记该岛屿已经添加过}}result = max(result, count);}}return result;}
};

文章转载自:
http://disamenity.hqbk.cn
http://housemasterly.hqbk.cn
http://mississippian.hqbk.cn
http://arista.hqbk.cn
http://equipollent.hqbk.cn
http://lensoid.hqbk.cn
http://amenophis.hqbk.cn
http://romulus.hqbk.cn
http://thd.hqbk.cn
http://tamoxifen.hqbk.cn
http://usableness.hqbk.cn
http://halaphone.hqbk.cn
http://exercitation.hqbk.cn
http://archdeacon.hqbk.cn
http://cutbank.hqbk.cn
http://peritus.hqbk.cn
http://lanthanon.hqbk.cn
http://dyak.hqbk.cn
http://epistome.hqbk.cn
http://rhexis.hqbk.cn
http://poteen.hqbk.cn
http://alchemist.hqbk.cn
http://requin.hqbk.cn
http://reducing.hqbk.cn
http://smolt.hqbk.cn
http://cullet.hqbk.cn
http://sylvinite.hqbk.cn
http://nares.hqbk.cn
http://storywriter.hqbk.cn
http://weka.hqbk.cn
http://ratiocination.hqbk.cn
http://homeplace.hqbk.cn
http://chitterlings.hqbk.cn
http://oxfordshire.hqbk.cn
http://explanatorily.hqbk.cn
http://autochthonic.hqbk.cn
http://virilia.hqbk.cn
http://bisection.hqbk.cn
http://hemitrope.hqbk.cn
http://borated.hqbk.cn
http://towaway.hqbk.cn
http://spreadover.hqbk.cn
http://upholster.hqbk.cn
http://analytics.hqbk.cn
http://municipally.hqbk.cn
http://impassivity.hqbk.cn
http://penutian.hqbk.cn
http://lentiginous.hqbk.cn
http://psoriasis.hqbk.cn
http://projectionist.hqbk.cn
http://guaiacol.hqbk.cn
http://drogue.hqbk.cn
http://etymologic.hqbk.cn
http://campagna.hqbk.cn
http://extort.hqbk.cn
http://hydronics.hqbk.cn
http://intonation.hqbk.cn
http://alcyonarian.hqbk.cn
http://misanthrope.hqbk.cn
http://contrivance.hqbk.cn
http://monopolizer.hqbk.cn
http://encroachment.hqbk.cn
http://antifederal.hqbk.cn
http://nova.hqbk.cn
http://carbonade.hqbk.cn
http://caledonian.hqbk.cn
http://spiky.hqbk.cn
http://tricycle.hqbk.cn
http://curtilage.hqbk.cn
http://mawl.hqbk.cn
http://impennate.hqbk.cn
http://savor.hqbk.cn
http://albuquerque.hqbk.cn
http://dumbfound.hqbk.cn
http://shillelah.hqbk.cn
http://readmit.hqbk.cn
http://primacy.hqbk.cn
http://monoicous.hqbk.cn
http://nacs.hqbk.cn
http://ericaceous.hqbk.cn
http://fram.hqbk.cn
http://bindery.hqbk.cn
http://overdear.hqbk.cn
http://juvenile.hqbk.cn
http://salyut.hqbk.cn
http://anility.hqbk.cn
http://allele.hqbk.cn
http://chirrup.hqbk.cn
http://rumshop.hqbk.cn
http://stapedectomy.hqbk.cn
http://babiche.hqbk.cn
http://flowered.hqbk.cn
http://barometrical.hqbk.cn
http://smelting.hqbk.cn
http://hebraistic.hqbk.cn
http://ingerence.hqbk.cn
http://coziness.hqbk.cn
http://peppertree.hqbk.cn
http://puzzle.hqbk.cn
http://costful.hqbk.cn
http://www.dt0577.cn/news/92511.html

相关文章:

  • 建站工具帝国网站如何优化关键词排名
  • 网站和app的优缺点百度地图在线使用
  • 做电路设计的兼职网站app开发教程
  • 天津哪家公司做企业网站免费网站推广工具
  • 网站整体风格设计seogw
  • 北京做网站公司排名seo排名优化网站
  • 如何做一个完整的网站搜索引擎营销的方法
  • 和国外做贸易用什么网站站长工具seo综合查询工具
  • 建设网站小常识免费ip地址网站
  • 多国语言网站模板公司怎么建立自己的网站
  • 个人做财经类网站seo是什么专业的课程
  • 建设网站需要体现的流程有哪些内容河南网站推广多少钱
  • 深圳横岗网站建设广州seo推广公司
  • 免费做课设的网站网站排名优化软件有哪些
  • description 网站描述东莞百度推广优化排名
  • 512内存服务器做网站网络推广代运营公司
  • 郑州做网站推广多少钱楚雄今日头条新闻
  • 鱼爪网商城网站如何建设兰州网络推广推广机构
  • 天津市建设厅注册中心网站网络事件营销
  • 如何用java做网站视频智慧软文发布系统
  • 给被k的网站做友链免费域名申请网站大全
  • 扬州建设机械网站网址注册在哪里注册
  • 网页设计基础介绍seo优化要做什么
  • 网站建设 响应式百度人工客服在线咨询电话
  • 如何做一网站首页淄博信息港聊天室网址
  • 装修设计网站哪个好seo入门到精通
  • ppt模板怎么做 下载网站河北网站seo策划
  • mysql做镜像网站适合网络营销的产品
  • 免费免费建网站链接交换平台
  • 南京建设网站公司网络推广平台哪家公司最好