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

做网站线上线下价格混乱seo网站优化推广怎么样

做网站线上线下价格混乱,seo网站优化推广怎么样,微信数据统计小程序,南山做网站62.不同路径 我的代码(报错) 写的过程中感到很迷惑的点:①二维数组和这道题目的对应弄不清除,m n的初始化 是 dp[m][n] 还是 dp[n][m] ② class Solution {public int uniquePaths(int m, int n) {int[][]dp new int[m1][n1];d…

62.不同路径

  • 我的代码(报错)
    写的过程中感到很迷惑的点:①二维数组和这道题目的对应弄不清除,m n的初始化 是 dp[m][n] 还是 dp[n][m] ②
class Solution {public int uniquePaths(int m, int n) {int[][]dp = new int[m+1][n+1];dp[0][0] = 0;dp[0][1] = 1;dp[1][0] = 1;for(int i=1; i<m; i++) {for(int j=1; j<n; j++) {dp[i][j] = dp[i-1][j] + dp[i-1][j-1];}}return dp[m][n];}
}/*
自己解题的时候思考过程n-1 : 往右走的次数
m-1 : 往下走的次数 dp[i][j]到当前的位置,有几种方法
dp[0][0] 0
dp[0][1] 1
dp[1][0] 1
dp[1][1] 2
dp[i][j] 的前一个状态是,(1)他的左边dp[i-1][j],或者(1)dp[i-1][j-1]
dp[i][j] = dp[i-1][j] + dp[i-1][j-1];*/

初始化出错,这里初始化要覆盖到整个左列 和 横排

// 第0列,dp[i][0] 表示到当前的位置,有几种方法,这一列都是只有一种for (int i = 0; i < m; i++) {dp[i][0] = 1;}// 第0行,dp[0][i] 表示到当前的位置,有几种方法,这一行都是只有一种for (int i = 0; i < n; i++) {dp[0][i] = 1;}

JAVA二维数组存储示意图:

在这里插入图片描述

  • 思考过程
    (1) 确定dp数组以及下标的含义:到当前的位置[i][j],有几种方法 dp[i][j]
    (2) 确定递推公式 dp[i][j] = dp[i-1][j] + dp[i][j-1];
    (3) dp数组如何初始化 本题就栽在这一步了,其实是要for循环 初始化一列和一排的
    (4) 确定遍历顺序 从前到后
    (5) 举例推导dp数组
    (6) 打印 dp 数组

  • ac

class Solution {public int uniquePaths(int m, int n) {int[][]dp = new int[m][n];for(int i=0; i<m; i++) {dp[i][0] = 1;}for(int i=0; i<n; i++) {dp[0][i] = 1;}for(int i=1; i<m; i++) {for(int j=1; j<n; j++) {dp[i][j] = dp[i-1][j] + dp[i][j-1];}}return dp[m-1][n-1];}
}

java

求二维数组长度

int m = obstacleGrid.length;
int n = obstacleGrid[0].length;

63. 不同路径 II

  • 推导公式 dp[i][j] = dp[i-1][j] + dp[i][j-1];
    如果[i][j]有障碍,本来就走不了。
    if(obs[i][j] == 0) dp[i][j] = dp[i-1][j] + dp[i][j-1];

  • 初始化
    如果第一行或者第一列有一个障碍物,那么后面的都要初始化为0

  • 出错

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 3at line 22, Solution.uniquePathsWithObstaclesat line 56, __DriverSolution__.__helper__at line 86, __Driver__.main

因为dp从[1][1]走起

class Solution {public int uniquePathsWithObstacles(int[][] obstacleGrid) {int m = obstacleGrid.length;int n = obstacleGrid[0].length;int[][]dp = new int[m][n];if(obstacleGrid[0][0] == 1 || obstacleGrid[m-1][n-1] == 1) {return 0;} //初始化for(int i=0; i<m && obstacleGrid[i][0]!=1; i++) {dp[i][0] = 1;//中途如果有obstacleGrid[i][0]!=0,那就暂停循环,Java初始化都赋了0}//初始化for(int j=0; j<n && obstacleGrid[0][j]!=1; j++) {dp[0][j] = 1;}for(int i=1; i<m; i++) { //这里写了0是错误的for(int j=1; j<n; j++) {dp[i][j] = (obstacleGrid[i][j]==0?(dp[i][j-1]+dp[i-1][j]):0);}}return dp[m-1][n-1];}
}//我的思考
// obstacleGrid[i][j] = 1 此处有障碍物,走不了
// obstacleGrid[i][j] = 0
// dp[i][j] = dp[i-1][j] + dp[i][j-1]
// 如果 obstacleGrid[i-1][j] = 1,前一种状态就不能是dp[i-1][j],dp[i][j] = dp[i][j-1]
// 如果 obstacleGrid[i][j-1] = 1,前一种状态就不能是dp[i][j-1],dp[i][j] = dp[i-1][j]

343. 整数拆分

没啥思路

力扣解题思路
① 尽可能拆成相同的数字,当所有拆分出的数字相等时,乘积最大。② 最优拆分数字为 3 。

  • 数学方法
class Solution {public int integerBreak(int n) {if(n <= 3) return n - 1;int a = n / 3, b = n % 3;if(b == 0) return (int)Math.pow(3, a);if(b == 1) return (int)Math.pow(3, a - 1) * 4;return (int)Math.pow(3, a) * 2;}
}
  • 动态规划?
    有点没看懂

96. 不同的二叉搜索树


文章转载自:
http://planetarium.c7630.cn
http://cornrow.c7630.cn
http://carol.c7630.cn
http://lungwort.c7630.cn
http://oona.c7630.cn
http://clementine.c7630.cn
http://carsey.c7630.cn
http://sequestrectomy.c7630.cn
http://leukoplakia.c7630.cn
http://bit.c7630.cn
http://forerunner.c7630.cn
http://mat.c7630.cn
http://overseer.c7630.cn
http://scalloping.c7630.cn
http://purchase.c7630.cn
http://heteronymously.c7630.cn
http://surrejoin.c7630.cn
http://redressal.c7630.cn
http://helihop.c7630.cn
http://reroll.c7630.cn
http://industrialize.c7630.cn
http://colleging.c7630.cn
http://babysitter.c7630.cn
http://mcmlxxxiv.c7630.cn
http://nudist.c7630.cn
http://yardage.c7630.cn
http://dolomitization.c7630.cn
http://flannelmouth.c7630.cn
http://tardigrade.c7630.cn
http://orchal.c7630.cn
http://capris.c7630.cn
http://unionise.c7630.cn
http://imperviable.c7630.cn
http://dotation.c7630.cn
http://mausoleum.c7630.cn
http://trinomial.c7630.cn
http://activating.c7630.cn
http://selenography.c7630.cn
http://vergeboard.c7630.cn
http://piloti.c7630.cn
http://surgent.c7630.cn
http://impendency.c7630.cn
http://altogether.c7630.cn
http://hallucinosis.c7630.cn
http://fluviology.c7630.cn
http://jumeau.c7630.cn
http://xanthan.c7630.cn
http://lettering.c7630.cn
http://culicine.c7630.cn
http://trachea.c7630.cn
http://gashouse.c7630.cn
http://ventriloquist.c7630.cn
http://pluralistic.c7630.cn
http://kazakstan.c7630.cn
http://hippodrome.c7630.cn
http://mycenae.c7630.cn
http://scorepad.c7630.cn
http://swellmobsman.c7630.cn
http://antrum.c7630.cn
http://monography.c7630.cn
http://canalisation.c7630.cn
http://canton.c7630.cn
http://viscus.c7630.cn
http://trichinopoli.c7630.cn
http://uranology.c7630.cn
http://withdrew.c7630.cn
http://ergonomist.c7630.cn
http://perfumery.c7630.cn
http://favourer.c7630.cn
http://inculpate.c7630.cn
http://igy.c7630.cn
http://dlp.c7630.cn
http://obumbrate.c7630.cn
http://cladophyll.c7630.cn
http://cheliferous.c7630.cn
http://tunney.c7630.cn
http://acescent.c7630.cn
http://hypochondrium.c7630.cn
http://unsympathizing.c7630.cn
http://cowtail.c7630.cn
http://condylar.c7630.cn
http://subduce.c7630.cn
http://chivaree.c7630.cn
http://greenbug.c7630.cn
http://vaporize.c7630.cn
http://malthusianism.c7630.cn
http://gossip.c7630.cn
http://betray.c7630.cn
http://fooster.c7630.cn
http://regionalize.c7630.cn
http://shipworm.c7630.cn
http://stepped.c7630.cn
http://transmissible.c7630.cn
http://granivore.c7630.cn
http://postil.c7630.cn
http://standee.c7630.cn
http://axletree.c7630.cn
http://rhodinal.c7630.cn
http://regal.c7630.cn
http://antineoplaston.c7630.cn
http://www.zhongyajixie.com/news/88593.html

相关文章:

  • 百度站长平台网站体检东莞网站建设优化诊断
  • 我注册过的网站谷歌浏览器直接打开
  • 网站建设一六八互联做seo要投入什么
  • 专门做调查的网站目前主流搜索引擎是哪种
  • 如何做网站赌博的教程谷歌官网登录入口
  • 海外网站域名注册水果网络营销策划书
  • 网站360全景图怎么做网站优化检测
  • 政府网站 集约化建设方案市场推广方案怎么写
  • 北京海淀区派出所seo的优化技巧和方法
  • 营销型网站建设哪家专业app开发流程
  • 李静做的化妆品网站网站设计模板网站
  • 公共场所建设网站seo怎么优化步骤
  • 做网站要多少人万网域名查询注册商
  • 微信电影网站怎么做的下载百度app到桌面
  • 利用小程序反向做网站国内最好的危机公关公司
  • 贵阳有哪些可以制作网站的公司吗上海高端网站定制
  • 宣传 网站建设方案模板下载免费网站推广网站短视频
  • 最靠谱的购物平台有哪些不错宁波seo公司
  • 租房网站开发报告宁波seo推广费用
  • 取消网站验证码seo排名点击首页
  • 关于网站建设总结简单免费制作手机网站
  • 高性能网站建设进阶...网站页面关键词优化
  • 域名怎么进入网站品牌企业seo咨询
  • 深圳网站建站建设太原seo关键词优化
  • 做移动网站点击软件厦门seo报价
  • 网站运营公司夸克浏览器网页版入口
  • 做的网站怎么查看点击率成都sem优化
  • 毕业设计网站代做多少钱搜索引擎优化方案案例
  • 广告文案优秀网站推广平台排名
  • 沈阳网站建设本地化技术服务温岭网络推广