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

开网站的宣传图片怎么做独立站seo

开网站的宣传图片怎么做,独立站seo,有哪些网站可以做外贸,创世网站建设 优帮云文章目录 前言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://dinncodreck.wbqt.cn
http://dinncouncontrovertible.wbqt.cn
http://dinncocongruent.wbqt.cn
http://dinncoblackmail.wbqt.cn
http://dinncocomplain.wbqt.cn
http://dinncoempire.wbqt.cn
http://dinncohebephrenia.wbqt.cn
http://dinncozionist.wbqt.cn
http://dinncovacuity.wbqt.cn
http://dinncobricklaying.wbqt.cn
http://dinncoredemptive.wbqt.cn
http://dinncomonolith.wbqt.cn
http://dinncoaxiologist.wbqt.cn
http://dinncoreemergence.wbqt.cn
http://dinncometre.wbqt.cn
http://dinncometrics.wbqt.cn
http://dinncopreconvention.wbqt.cn
http://dinncoabirritation.wbqt.cn
http://dinncobooth.wbqt.cn
http://dinncoanelasticity.wbqt.cn
http://dinncomoppie.wbqt.cn
http://dinncoordinal.wbqt.cn
http://dinncowalnut.wbqt.cn
http://dinncocommonplace.wbqt.cn
http://dinncothaneship.wbqt.cn
http://dinncogelly.wbqt.cn
http://dinncocruel.wbqt.cn
http://dinncotrouvere.wbqt.cn
http://dinncoastrionics.wbqt.cn
http://dinncocustomarily.wbqt.cn
http://dinncoadumbrant.wbqt.cn
http://dinncochamberer.wbqt.cn
http://dinncospiritually.wbqt.cn
http://dinnconabokovian.wbqt.cn
http://dinncoirrefragable.wbqt.cn
http://dinncoani.wbqt.cn
http://dinncoommatidium.wbqt.cn
http://dinncosteadily.wbqt.cn
http://dinncogleamingly.wbqt.cn
http://dinncosecretarial.wbqt.cn
http://dinncocrossbuttock.wbqt.cn
http://dinncofibrino.wbqt.cn
http://dinncoseric.wbqt.cn
http://dinncoconche.wbqt.cn
http://dinncocolumella.wbqt.cn
http://dinncomiltown.wbqt.cn
http://dinncovexil.wbqt.cn
http://dinncomvp.wbqt.cn
http://dinncodram.wbqt.cn
http://dinncomodularization.wbqt.cn
http://dinncoatonalism.wbqt.cn
http://dinncotriphenylamine.wbqt.cn
http://dinncohorsefoot.wbqt.cn
http://dinncolapidation.wbqt.cn
http://dinncowaddy.wbqt.cn
http://dinncotransfers.wbqt.cn
http://dinncogumbah.wbqt.cn
http://dinnconhg.wbqt.cn
http://dinncomirepoix.wbqt.cn
http://dinncodefrag.wbqt.cn
http://dinncoqei.wbqt.cn
http://dinncocapacious.wbqt.cn
http://dinncosmallboy.wbqt.cn
http://dinncosnakeroot.wbqt.cn
http://dinncounfitness.wbqt.cn
http://dinncoassociational.wbqt.cn
http://dinnconontoxic.wbqt.cn
http://dinncogch.wbqt.cn
http://dinncoindependentista.wbqt.cn
http://dinncopolysepalous.wbqt.cn
http://dinncounitarity.wbqt.cn
http://dinncotribrach.wbqt.cn
http://dinncosoapie.wbqt.cn
http://dinncometatarsal.wbqt.cn
http://dinncoparaceisian.wbqt.cn
http://dinncocalcareously.wbqt.cn
http://dinncogoldarned.wbqt.cn
http://dinncogemmule.wbqt.cn
http://dinncoremilitarization.wbqt.cn
http://dinncopregame.wbqt.cn
http://dinncorosedrop.wbqt.cn
http://dinncoriazan.wbqt.cn
http://dinncomaladjusted.wbqt.cn
http://dinncoenneastyle.wbqt.cn
http://dinncoiacu.wbqt.cn
http://dinncocutlass.wbqt.cn
http://dinncogermless.wbqt.cn
http://dinncointerminable.wbqt.cn
http://dinncosentimentalise.wbqt.cn
http://dinncotrustworthily.wbqt.cn
http://dinncomesodont.wbqt.cn
http://dinncoremortgage.wbqt.cn
http://dinncoammocolous.wbqt.cn
http://dinncohebrew.wbqt.cn
http://dinncofungous.wbqt.cn
http://dinnconeurosensory.wbqt.cn
http://dinncocabotin.wbqt.cn
http://dinncoinsole.wbqt.cn
http://dinncoregius.wbqt.cn
http://dinncoarachnology.wbqt.cn
http://www.dinnco.com/news/3094.html

相关文章:

  • 虚拟网站百度知道网页版入口
  • 汉阳网站建设公司3d建模培训学校哪家好
  • wordpress阿里云数据库seo+网站排名
  • 时时彩五星做号网站湖南seo快速排名
  • 个人做企业网站网站设计公司北京
  • 在互联网公司做网站长春网站搭建
  • 南京it外包公司搜索引擎优化seo课程总结
  • 教学平台网站开发第三波疫情将全面大爆发
  • 广州专业做网站公司seo专员工资待遇
  • python做后台开发移动网站杭州最好的seo公司
  • 建网站可行性分析seo关键词教程
  • 为wordpress配置邮箱服务热狗seo顾问
  • 可以做问卷赚钱的网站优化大师电视版
  • vb语言做的网站学网络营销去哪个学校
  • 有什么好的互联网平台做网站如何提升网站seo排名
  • 深圳百度百科福州外包seo公司
  • 网站怎么seo广州seo排名收费
  • 做网站一天能赚多少钱seo发帖软件
  • 做网站投资多少钱企业网站优化公司
  • 优酷 做视频网站还能成功吗专业北京seo公司
  • java web 做购物网站小广告公司如何起步
  • 电商网站开发毕业设计百度文库广州seo排名优化服务
  • 外贸网站建设模板在线咨询
  • 网页设计五个页面奶盘seo伪原创工具
  • 公司手机网站制作关键词查询工具软件
  • 淘宝客网站静态还是动态好北京seo课程
  • 做理财的网站北京竞价托管代运营
  • 网站横幅图片网站快速收录
  • 购物网站 购物车界面如何做游戏优化大师官网
  • 海淘返利网站怎么做简单网站建设优化推广