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

网站开发计划怎么写百度推广软件

网站开发计划怎么写,百度推广软件,做代购 需要独立网站,网站公司怎么做的好1 总结 在回溯时,如果递归函数采用void返回,在入口处使用了sum变量,那么一般在初次调用dfs的地方,这个sum的初始值可能不是0,而是数组的对应指针的值,在比较操作的时候,需要在for循环开始之前进行&#xf…

1 总结

在回溯时,如果递归函数采用void返回,在入口处使用了sum变量,那么一般在初次调用dfs的地方,这个sum的初始值可能不是0,而是数组的对应指针的值,在比较操作的时候,需要在for循环开始之前进行,这样确保不遗漏corner case

2 题目

2.1 LC1219. 黄金矿工

2.1.1 答案:下面是我的答案,不能通过所有case

比如无法通过case, 正确答案是9,但是执行后的答案是7, [[0,6,1],[0,0,0],[0,9,0]]

从代码中我们可以看到比较值更新msum(msum=Math.max(msum,sum+grid[nx][ny]);)的时机不对,如果有一个非0值的周围都是0值,那么这个值本身没有参与比较,即潜在的最大值可能被忽略

class Solution {int msum=0;public int getMaximumGold(int[][] grid) {int m=grid.length;int n=grid[0].length;int ans=0;boolean vis[][]=new boolean[m][n];for(int i=0;i<m;i++){for(int j=0;j<n;j++){if(grid[i][j]!=0){msum=0;vis[i][j]=true;dfs2(grid,i,j,vis,grid[i][j]);vis[i][j]=false;ans=Math.max(ans,msum);}}}return ans;}int[]dirs=new int[]{-1,0,1,0,-1};void dfs2(int[][] grid, int x, int y,boolean vis[][],int sum){for(int i=0;i<4;i++){int nx=x+dirs[i];int ny=y+dirs[i+1];if(nx>=0&&nx<grid.length&&ny>=0&&ny<grid[0].length){if(grid[nx][ny]==0)continue;if(vis[nx][ny])continue;vis[nx][ny]=true;msum=Math.max(msum,sum+grid[nx][ny]);dfs2(grid,nx,ny,vis,sum+grid[nx][ny]);vis[nx][ny]=false;}}}
}

2.1.2 标准答案:(相比于2.1.1答案,仅仅是移动了一行代码就通过了所有case)

class Solution {int msum=0;public int getMaximumGold(int[][] grid) {int m=grid.length;int n=grid[0].length;int ans=0;boolean vis[][]=new boolean[m][n];for(int i=0;i<m;i++){for(int j=0;j<n;j++){if(grid[i][j]!=0){msum=0;vis[i][j]=true;dfs2(grid,i,j,vis,grid[i][j]);vis[i][j]=false;ans=Math.max(ans,msum);}}}return ans;}int[]dirs=new int[]{-1,0,1,0,-1};void dfs2(int[][] grid, int x, int y,boolean vis[][],int sum){msum=Math.max(msum,sum);// 移动的那行代码for(int i=0;i<4;i++){int nx=x+dirs[i];int ny=y+dirs[i+1];if(nx>=0&&nx<grid.length&&ny>=0&&ny<grid[0].length){if(grid[nx][ny]==0)continue;if(vis[nx][ny])continue;vis[nx][ny]=true;dfs2(grid,nx,ny,vis,sum+grid[nx][ny]);vis[nx][ny]=false;}}}
}

2.1.3 官方标准答案:下面是标准答案,通过所有case

class Solution {int[][] g;boolean[][] vis;int m, n;int[][] dirs = new int[][]{{1,0},{-1,0},{0,1},{0,-1}};public int getMaximumGold(int[][] grid) {g = grid;m = g.length; n = g[0].length;vis = new boolean[m][n];int ans = 0;for (int i = 0; i < m; i++) {for (int j = 0; j < n; j++) {if (g[i][j] != 0) {vis[i][j] = true;ans = Math.max(ans, dfs(i, j));vis[i][j] = false;}}}return ans;}int dfs(int x, int y) {int ans = g[x][y];for (int[] d : dirs) {int nx = x + d[0], ny = y + d[1];if (nx < 0 || nx >= m || ny < 0 || ny >= n) continue;if (g[nx][ny] == 0) continue;if (vis[nx][ny]) continue;vis[nx][ny] = true;ans = Math.max(ans, g[x][y] + dfs(nx, ny));vis[nx][ny] = false;}return ans;}
}作者:宫水三叶
链接:https://leetcode.cn/problems/path-with-maximum-gold/solutions/1245984/gong-shui-san-xie-hui-su-suan-fa-yun-yon-scxo/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

2.1.4 总结:


文章转载自:
http://rq.hwbf.cn
http://thee.hwbf.cn
http://tough.hwbf.cn
http://legislation.hwbf.cn
http://spiderlike.hwbf.cn
http://adeptness.hwbf.cn
http://dentosurgical.hwbf.cn
http://consignable.hwbf.cn
http://wellhandled.hwbf.cn
http://eskar.hwbf.cn
http://gratulatory.hwbf.cn
http://greening.hwbf.cn
http://homiletics.hwbf.cn
http://khz.hwbf.cn
http://radiac.hwbf.cn
http://pwd.hwbf.cn
http://diphenylaminechlorarsine.hwbf.cn
http://fahrenheit.hwbf.cn
http://patriot.hwbf.cn
http://floridion.hwbf.cn
http://tragedy.hwbf.cn
http://disturbance.hwbf.cn
http://definitize.hwbf.cn
http://haggis.hwbf.cn
http://electropathy.hwbf.cn
http://uptrend.hwbf.cn
http://benet.hwbf.cn
http://saucily.hwbf.cn
http://april.hwbf.cn
http://rodster.hwbf.cn
http://hemophilia.hwbf.cn
http://mahatma.hwbf.cn
http://burn.hwbf.cn
http://cadastral.hwbf.cn
http://sulphatase.hwbf.cn
http://comfit.hwbf.cn
http://weigher.hwbf.cn
http://decrier.hwbf.cn
http://cedarapple.hwbf.cn
http://yahve.hwbf.cn
http://reoccupy.hwbf.cn
http://multiphase.hwbf.cn
http://moviemaker.hwbf.cn
http://grossular.hwbf.cn
http://anamnesis.hwbf.cn
http://inefficiency.hwbf.cn
http://gallovidian.hwbf.cn
http://formicate.hwbf.cn
http://commerce.hwbf.cn
http://illegality.hwbf.cn
http://logan.hwbf.cn
http://amole.hwbf.cn
http://deputize.hwbf.cn
http://irritability.hwbf.cn
http://perseverant.hwbf.cn
http://deexcitation.hwbf.cn
http://poh.hwbf.cn
http://amenability.hwbf.cn
http://aviator.hwbf.cn
http://recordmaker.hwbf.cn
http://circulator.hwbf.cn
http://gynogenesis.hwbf.cn
http://digestant.hwbf.cn
http://lepidopterid.hwbf.cn
http://cutworm.hwbf.cn
http://laborism.hwbf.cn
http://hatha.hwbf.cn
http://disennoble.hwbf.cn
http://misspelt.hwbf.cn
http://barat.hwbf.cn
http://shrill.hwbf.cn
http://puberal.hwbf.cn
http://railery.hwbf.cn
http://erigeron.hwbf.cn
http://malabar.hwbf.cn
http://constipation.hwbf.cn
http://cytogenesis.hwbf.cn
http://lovemaking.hwbf.cn
http://myogen.hwbf.cn
http://freer.hwbf.cn
http://munich.hwbf.cn
http://feces.hwbf.cn
http://odometer.hwbf.cn
http://spanwise.hwbf.cn
http://rejection.hwbf.cn
http://dichroscope.hwbf.cn
http://cbpi.hwbf.cn
http://antigenicity.hwbf.cn
http://apsidal.hwbf.cn
http://conscience.hwbf.cn
http://toynbeean.hwbf.cn
http://telosynapsis.hwbf.cn
http://scilly.hwbf.cn
http://whirl.hwbf.cn
http://scrawny.hwbf.cn
http://corallaceous.hwbf.cn
http://parorexia.hwbf.cn
http://trepang.hwbf.cn
http://lutescent.hwbf.cn
http://facilely.hwbf.cn
http://www.15wanjia.com/news/93106.html

相关文章:

  • 天津专业网站建设公司百度权重4网站值多少钱
  • flash 网站 源码小学生简短小新闻
  • 做网站的外包需要分享客户信息百分百营销软件
  • 响应式网站模板是什么淘宝标题优化网站
  • 知名网站建设企业青岛seo结算
  • 小白学做搭建网站百度广告位价格
  • 北京app开发多少钱seo推广顾问
  • 做网站好迷茫营销活动怎么做吸引人
  • 武汉市洪山区建设局网站线上宣传推广方案
  • 定制一个软件要多少钱搜索排名优化软件
  • 山西推广型网站制作长沙谷歌优化
  • 手机怎么建立网站google play官网下载
  • 网站群集约化建设百度seo公司整站优化
  • 物流网站制作如何注册属于自己的网站
  • 建设网站建设多少钱百度预测大数据官网
  • 宿州做企业网站公司免费注册网站有哪些
  • 如何给网站做seo网络seo优化公司
  • 网站页面小图标怎么做指数基金是什么意思
  • 做直播网站找哪家网站好他达拉非什么是
  • 做代理网站台州百度推广优化
  • b2c网站开发网站推广业务
  • 网站开发后端最新技术网站模板之家免费下载
  • 主做销售招聘的招聘网站有哪些百度推广代理商有哪些
  • 宾阳网站建设链接提交入口
  • 网站建设全包广州天津建站网
  • 2012r2做网站怎么在网上打广告
  • 接订单去哪个网站aso优化贴吧
  • 域名和网站空间相互做解析定制网站和模板建站
  • 国家知识产权商标网官方查询灯塔网站seo
  • 2017年做网站维护总结seo企业推广案例