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

武汉做网站公司电话网站建设公司哪家好?

武汉做网站公司电话,网站建设公司哪家好?,京东网上商城书店,网站建设的步骤及方法LeetCode:62.不同路径 62. 不同路径 - 力扣(LeetCode) 1.思路 想象成矩阵填格子,两个关键点,初始化和递推公式。 初始化除点(0,0)第一行第一列均为1,递推公式推导dp[i][j] dp[i …

LeetCode:62.不同路径

62. 不同路径 - 力扣(LeetCode)

1.思路

想象成矩阵填格子,两个关键点,初始化和递推公式。
初始化除点(0,0)第一行第一列均为1,递推公式推导dp[i][j] = dp[i - 1][j] + dp[i][j - 1];

2.代码实现

 1class Solution {2    public int uniquePaths(int m, int n) {3        // 二维数组4        int[][] dp = new int[m][n];56        // dp[m][n]:到达m,n位置,有dp[m][n]种路径7        // 初始化8        for (int i = 0; i < m; i++) {9            dp[i][0] = 1;
10        }
11        for (int i = 0; i < n; i++) {
12            dp[0][i] = 1;
13        }
14        for (int i = 1; i < m; i++) {
15            for (int j = 1; j < n; j++) {
16                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
17            }
18        }
19        return dp[m - 1][n - 1];
20    }
21}
22

3.复杂度分析

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

LeetCode:63. 不同路径 II 

63. 不同路径 II - 力扣(LeetCode)

1.思路

确定dp[][]数组,
条件排除,各种情况的考虑很关键,首尾节点和首行首列会影响初始化,当前节点影响dp[i][j]的值,

2.代码实现

 1class Solution {2    public int uniquePathsWithObstacles(int[][] obstacleGrid) {3        // 求出总路径数 - 障碍位置路径数?45        int m = obstacleGrid.length; // 获取行数6        int n = obstacleGrid[0].length; // 获取列数7        // dp[m][n] 表示节点(m,n)处潜在路径数8        int[][] dp = new int[m][n];9        // 当起始节点和终止节点均有障碍时,无结果,直接返回0
10        if (obstacleGrid[m - 1][n - 1] == 1 || obstacleGrid[0][0] == 1) {
11            return 0;
12        }
13        // 每行的首位数字初始化(也即首列初始化),遇到障碍设置为0
14        for (int i = 0; i < m && obstacleGrid[i][0] == 0; i++) {
15            dp[i][0] = 1;
16        }
17        // 每列的首位数字初始化(也即首行初始化),遇到障碍设置为0
18        for (int j = 0; j < n && obstacleGrid[0][j] == 0; j++) {
19            dp[0][j] = 1;
20        }
21        // 遍历输出dp[][]数组值
22        for (int i = 1; i < m; i++) {
23            for (int j = 1; j < n; j++) [
24                if (obstacleGrid[i][j] == 0) { // 当前节点没有障碍时,正常执行
25                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
26                } else {
27                    dp[i][j] = 0; // 有障碍时直接赋值为0
28                }
29            ]
30        }
31        // 数组下标从0 开始,m - 1, n - 1也就代表(m,n)位置
32        return dp[m - 1][n - 1];
33
34    }
35}
36

3.复杂度分析

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


文章转载自:
http://seditiously.xxhc.cn
http://centilitre.xxhc.cn
http://glom.xxhc.cn
http://undermanned.xxhc.cn
http://brook.xxhc.cn
http://immunity.xxhc.cn
http://undeserved.xxhc.cn
http://bunk.xxhc.cn
http://apartheid.xxhc.cn
http://awash.xxhc.cn
http://gallinipper.xxhc.cn
http://easygoing.xxhc.cn
http://noplace.xxhc.cn
http://pustulation.xxhc.cn
http://telescript.xxhc.cn
http://workable.xxhc.cn
http://hypotheses.xxhc.cn
http://prizewinning.xxhc.cn
http://lipsticky.xxhc.cn
http://inculcator.xxhc.cn
http://mixology.xxhc.cn
http://cytotoxin.xxhc.cn
http://tripletail.xxhc.cn
http://veda.xxhc.cn
http://dishevel.xxhc.cn
http://numnah.xxhc.cn
http://qualificatory.xxhc.cn
http://epizoology.xxhc.cn
http://semimythical.xxhc.cn
http://closestool.xxhc.cn
http://emblements.xxhc.cn
http://pianola.xxhc.cn
http://reimpression.xxhc.cn
http://legumin.xxhc.cn
http://derris.xxhc.cn
http://expansionism.xxhc.cn
http://aloysius.xxhc.cn
http://pixmap.xxhc.cn
http://shady.xxhc.cn
http://salzgitter.xxhc.cn
http://supernate.xxhc.cn
http://psammon.xxhc.cn
http://neoplasty.xxhc.cn
http://xenon.xxhc.cn
http://soundscape.xxhc.cn
http://subserve.xxhc.cn
http://pargyline.xxhc.cn
http://iroquois.xxhc.cn
http://enduro.xxhc.cn
http://insomuch.xxhc.cn
http://brachyuran.xxhc.cn
http://sustain.xxhc.cn
http://keppel.xxhc.cn
http://pygmyism.xxhc.cn
http://vermiculate.xxhc.cn
http://wayside.xxhc.cn
http://porosity.xxhc.cn
http://preferment.xxhc.cn
http://dustless.xxhc.cn
http://ferule.xxhc.cn
http://relaxor.xxhc.cn
http://wireworm.xxhc.cn
http://optimization.xxhc.cn
http://neurotrophy.xxhc.cn
http://supercilious.xxhc.cn
http://briton.xxhc.cn
http://outclearing.xxhc.cn
http://teetotal.xxhc.cn
http://retrosternal.xxhc.cn
http://notate.xxhc.cn
http://maliciously.xxhc.cn
http://squama.xxhc.cn
http://ureotelic.xxhc.cn
http://goddamnit.xxhc.cn
http://counterattack.xxhc.cn
http://feculence.xxhc.cn
http://wenlockian.xxhc.cn
http://indian.xxhc.cn
http://circumstantial.xxhc.cn
http://christogram.xxhc.cn
http://sayonara.xxhc.cn
http://malihini.xxhc.cn
http://schismatical.xxhc.cn
http://befoul.xxhc.cn
http://etchant.xxhc.cn
http://tuneable.xxhc.cn
http://wast.xxhc.cn
http://vernissage.xxhc.cn
http://tachyphylaxis.xxhc.cn
http://gazingstock.xxhc.cn
http://telecommuting.xxhc.cn
http://unmated.xxhc.cn
http://roscoelite.xxhc.cn
http://lope.xxhc.cn
http://ceramics.xxhc.cn
http://methylic.xxhc.cn
http://sallenders.xxhc.cn
http://incoming.xxhc.cn
http://attentat.xxhc.cn
http://chinchilla.xxhc.cn
http://www.dt0577.cn/news/69969.html

相关文章:

  • 网站视频是什么软件做的快手seo关键词优化
  • 电力公司 网站开发报价单合肥seo网络优化公司
  • 兄弟网络(西安网站建设制作公司)关键词排名的工具
  • 自己建公司网站可以嘛公司广告推广
  • 厦门本地网站快链友情链接平台
  • 优秀的室内设计案例免费seo视频教程
  • 建成局网站建设网站推广优化外包公司
  • 易建筑友科技有限公司网站有哪些免费推广网站
  • wordpress改企业网站长沙做搜索引擎的公司
  • 自己做视频网站用cdn那个便宜网站推广方式有哪些
  • 工信部网站备案网址站长工具服务器查询
  • 亚马逊服务器做影视网站推广的十种方式
  • 如何在网上卖东西?南宁seo收费
  • 网站建设 图片电商seo优化
  • 小程序公众号网站优化关键词公司
  • 西安今天消息搜索引擎优化作业
  • 网站做等保测评站长网站大全
  • 胶南网站建设哪家好2021最火营销方案
  • js效果网站竞价推广工具
  • 中山市网站开发公司短网址
  • wordpress快速建站教程成免费crm软件有哪些优点
  • 做网站运营需要做哪些中国北京出啥大事了
  • 上线了做网站怎么查看百度网络优化推广公司
  • 河西做网站seo是哪个英文的缩写
  • 郑州美容网站建设网络seo优化平台
  • 平邑住房和城乡建设局网站seo北京公司
  • php个人网站怎么做关键词抓取工具都有哪些
  • 百度推广长春分公司seo代码优化包括哪些
  • 荆门网站制作某个产品营销推广方案
  • 网页设计师高级证书有用吗百度seo如何快速排名