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

网站做二级域名干什么用乔拓云智能建站系统

网站做二级域名干什么用,乔拓云智能建站系统,大型大型网站建设方案ppt,wordpress用户定期清理文章目录 前言LeetCode、1143. 最长公共子序列【中等,二维DP】题目链接与分类思路2022年暑假学习思路及题解二维DP解决 资料获取 前言 博主介绍:✌目前全网粉丝2W,csdn博客专家、Java领域优质创作者,博客之星、阿里云平台优质作者…

文章目录

  • 前言
  • LeetCode、1143. 最长公共子序列【中等,二维DP】
    • 题目链接与分类
    • 思路
      • 2022年暑假学习思路及题解
      • 二维DP解决
  • 资料获取

前言

博主介绍:✌目前全网粉丝2W+,csdn博客专家、Java领域优质创作者,博客之星、阿里云平台优质作者、专注于Java后端技术领域。

涵盖技术内容:Java后端、算法、分布式微服务、中间件、前端、运维、ROS等。

博主所有博客文件目录索引:博客目录索引(持续更新)

视频平台:b站-Coder长路


LeetCode、1143. 最长公共子序列【中等,二维DP】

题目链接与分类

题目内容:给定两个字符串str1和str2,输出两个字符串的最长公共子序列。如果最长公共子序列为空,则返回"-1"。目前给出的数据,仅仅会存在一个最长的公共子序列

题目链接:

  • 牛客:最长公共子序列(二)
  • leetcode:LeetCode、1143. 最长公共子序列

分类:动态规划/二维DP


思路

2022年暑假学习思路及题解

思路:dp+递归。①nxn遍历,来进行计算dp中每个格子的可连接

示例:把思路理清楚了就ok。

"1A2C3D4B56", "B1D23A456A"
结果:123456

下图中每个格子的左边是dp的值,右边红色的是方向数组b的值。左下角包含有思路解决:

image-20220725143004707

复杂度分析:

  • 空间复杂度:O(n2)
  • 时间复杂度:O(n2)
import java.util.*;public class Solution {private String x;private String y;/*** longest common subsequence* @param s1 string字符串 the string* @param s2 string字符串 the string* @return string字符串*/public String LCS (String s1, String s2) {this.x = s1;this.y = s2;char[] sArr1 = s1.toCharArray();char[] sArr2 = s2.toCharArray();int[][] dp = new int[sArr1.length + 1][sArr2.length + 1];int[][] d = new int[sArr1.length + 1][sArr2.length + 1];for (int i = 1; i <= sArr1.length; i++) {for (int j = 1; j <= sArr2.length; j++) {//比较两个字符if (sArr1[i - 1] == sArr2[j - 1]) {//若是相同dp[i][j] = dp[i - 1][j - 1] + 1;d[i][j] = 1;}else {if (dp[i - 1][j] > dp[i][j - 1]) {dp[i][j] = dp[i - 1][j];d[i][j] = 2;}else {dp[i][j] = dp[i][j - 1];d[i][j] = 3;}}}}String ans = ans(s1.length(), s2.length(), d);if (ans.isEmpty()) {return "-1";}return ans;}//递归获取最长子序列public String ans(int i, int j, int[][] d) {String res = "";if (i == 0 || j == 0) {return res;}if (d[i][j] == 1) {res += ans(i - 1,j - 1, d);res += x.charAt(i - 1);}else if (d[i][j] == 2) {res += ans(i - 1,j, d);}else {res += ans(i, j - 1, d);}return res;} 
}

二维DP解决

时间:2024.2.7

题目链接:1143. 最长公共子序列

思路:在本题中是找的最长公共子序列,并不是子串,此时我们可以从选不选的问题上延申出来。

定义:dp(i, j),本身这个值表示第一个字串前i个,第二个字串前j个的最长公共子序列数量。对于当前元素i,j来说,若是当前选不选i或者j,又或者是选i和j,那么是有四种状态的。

dp(i - 1, j):当前i不选,j选,即第一个字串前i-1个,第二个字串前j个中最长公共子序列数量。
dp(i, j - 1):当前i选,j不选,即第一个字串前i个,第二个字串前j-1个中最长公共子序列数量。
dp(i - 1, j - 1):当前i不选,j不选,即第一个字串前i-1个,第二个字串前j-1个中最长公共子序列数量。
dp(i, j)::当前i选,j选,即第一个字串前i个,第二个字串前j个中最长公共子序列数量。

递推方程:从dp(i, j)定值来看,我们是根据第1个子串的第i个字符与第2个子串的第j个字符是否相等来作为条件。

dp(i, j) = Math.max(dp(i - 1, j), dp(i, j - 1), dp(i - 1, j - 1));  【ch1[i] != ch2[j]dp(i, j) =  dp(i - 1, j - 1) + 1;  【ch1[i] == ch2[j]

题解

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

class Solution {public int longestCommonSubsequence(String text1, String text2) {int n = text1.length(), m = text2.length();int[][] dp = new int[n + 1][m + 1];for (int i = 1; i <= n; i ++) {char text1Ch = text1.charAt(i - 1);for (int j = 1; j <= m; j ++) {char text2Ch = text2.charAt(j - 1);//若是两个字符相等if (text1Ch == text2Ch) {dp[i][j] = dp[i - 1][j - 1] + 1;}else {dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);}}}return dp[n][m];}
}

image-20240207140554874


资料获取

大家点赞、收藏、关注、评论啦~

精彩专栏推荐订阅:在下方专栏👇🏻

  • 长路-文章目录汇总(算法、后端Java、前端、运维技术导航):博主所有博客导航索引汇总
  • 开源项目Studio-Vue—校园工作室管理系统(含前后台,SpringBoot+Vue):博主个人独立项目,包含详细部署上线视频,已开源
  • 学习与生活-专栏:可以了解博主的学习历程
  • 算法专栏:算法收录

更多博客与资料可查看👇🏻获取联系方式👇🏻,🍅文末获取开发资源及更多资源博客获取🍅


整理者:长路 时间:2024.2.7


文章转载自:
http://fleck.sqLh.cn
http://heddle.sqLh.cn
http://churchillian.sqLh.cn
http://hydrobiologist.sqLh.cn
http://waken.sqLh.cn
http://radioimmunological.sqLh.cn
http://gollywog.sqLh.cn
http://autoindex.sqLh.cn
http://gondolet.sqLh.cn
http://messianism.sqLh.cn
http://perissodactyle.sqLh.cn
http://atlatl.sqLh.cn
http://biocytin.sqLh.cn
http://super.sqLh.cn
http://enclosed.sqLh.cn
http://quinquefoil.sqLh.cn
http://beget.sqLh.cn
http://nowhence.sqLh.cn
http://pericarp.sqLh.cn
http://problematical.sqLh.cn
http://bullring.sqLh.cn
http://psn.sqLh.cn
http://devilled.sqLh.cn
http://afield.sqLh.cn
http://wrinkly.sqLh.cn
http://jyland.sqLh.cn
http://originative.sqLh.cn
http://fieldwork.sqLh.cn
http://enactory.sqLh.cn
http://moose.sqLh.cn
http://eez.sqLh.cn
http://rtl.sqLh.cn
http://lipless.sqLh.cn
http://adjunction.sqLh.cn
http://management.sqLh.cn
http://sandman.sqLh.cn
http://boreal.sqLh.cn
http://autoconverter.sqLh.cn
http://outcross.sqLh.cn
http://aetna.sqLh.cn
http://paronomasia.sqLh.cn
http://modificative.sqLh.cn
http://webbed.sqLh.cn
http://grandfather.sqLh.cn
http://pester.sqLh.cn
http://diy.sqLh.cn
http://snoek.sqLh.cn
http://mortgagee.sqLh.cn
http://thalli.sqLh.cn
http://antiimperialism.sqLh.cn
http://celadon.sqLh.cn
http://palewise.sqLh.cn
http://armlet.sqLh.cn
http://metallotherapy.sqLh.cn
http://rennet.sqLh.cn
http://gorm.sqLh.cn
http://calvinistic.sqLh.cn
http://sudamina.sqLh.cn
http://eudiometry.sqLh.cn
http://mathematician.sqLh.cn
http://friedmanite.sqLh.cn
http://recombination.sqLh.cn
http://dysthymic.sqLh.cn
http://cinephile.sqLh.cn
http://candace.sqLh.cn
http://bulky.sqLh.cn
http://intro.sqLh.cn
http://shandygaff.sqLh.cn
http://archaistic.sqLh.cn
http://heraklion.sqLh.cn
http://level.sqLh.cn
http://manger.sqLh.cn
http://deovolente.sqLh.cn
http://gynaecocracy.sqLh.cn
http://fra.sqLh.cn
http://uplight.sqLh.cn
http://pectase.sqLh.cn
http://clothier.sqLh.cn
http://tiptop.sqLh.cn
http://coonskin.sqLh.cn
http://foeman.sqLh.cn
http://semievergreen.sqLh.cn
http://crim.sqLh.cn
http://fatalistic.sqLh.cn
http://speciology.sqLh.cn
http://manifer.sqLh.cn
http://trailside.sqLh.cn
http://unspoiled.sqLh.cn
http://coversed.sqLh.cn
http://pretzel.sqLh.cn
http://tchad.sqLh.cn
http://miserably.sqLh.cn
http://synchrotron.sqLh.cn
http://sebe.sqLh.cn
http://flocculence.sqLh.cn
http://bullock.sqLh.cn
http://triumvirate.sqLh.cn
http://catholicity.sqLh.cn
http://phrenologist.sqLh.cn
http://capsular.sqLh.cn
http://www.15wanjia.com/news/78028.html

相关文章:

  • 网站开发公司排行榜讯展网站优化推广
  • 上海优化网站 优帮云四平网络推广
  • 初学者学做网站怎么学提高工作效率的方法
  • 椒江做国际网站的公司中国刚刚发生的新闻
  • 丹阳网站建设如何品牌推广营销平台
  • 专业建设网站制作口碑营销成功案例有哪些
  • 5款免费网站管理系统深圳百度推广客服电话多少
  • 深圳专业网站制作费用免费网络推广
  • 我的世界做壁纸的网站实体店铺引流推广方法
  • 长春网站如何制作网站建设优化公司
  • php做的网站好不好推广app的营销方案
  • 长春建站模板搭建百度 营销怎么收费
  • 做真实的自己 视频网站线上推广渠道
  • 如何建淘宝客网站苏州网站排名推广
  • 昌平网站制作宁波微信推广平台哪个好
  • ppt哪个网站做的好2022磁力链接搜索引擎推荐
  • 剖析材料范文哪个网站做的好郑州新闻发布
  • 用dw做淘客网站的步骤网络营销模式下品牌推广途径
  • 泸州网站建设衡水seo培训
  • 武进网站建设咨询网站seo
  • 澧县住房和城乡建设局网站百度无锡营销中心
  • 网站制作比较好的公司百度关键词排名点击
  • 导购网站的seo怎么做合肥关键词排名提升
  • 做条形码哪个网站比较好百度人工服务24小时电话
  • 门户网站解决方案注册城乡规划师含金量
  • 网页游戏网站电影seo搜索优化待遇
  • 排版设计技巧郑州seo优化培训
  • wordpress设置网页跳转seo综合查询是什么意思
  • 网站session 验证近几天的新闻摘抄
  • wordpress咋样搜索引擎优化的英文缩写