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

男女生做内个的网站网络推广客服好做吗

男女生做内个的网站,网络推广客服好做吗,wordpress 汽车租赁,html写的网页怎么在手机上看392.判断子序列 题目:392. 判断子序列 - 力扣(LeetCode) 思路:定义重合数记录s与t的比对情况,挨个取出t的字符,与s的字符进行比较,如果相同,重合数就加1,跳到s的下一个字…

392.判断子序列

题目:392. 判断子序列 - 力扣(LeetCode)

思路:定义重合数记录s与t的比对情况,挨个取出t的字符,与s的字符进行比较,如果相同,重合数就加1,跳到s的下一个字符进行比较,最后判断重合数是否为s字符串长度

尝试(暴力AC)
class Solution {public boolean isSubsequence(String s, String t) {if(s.length()==0) return true;int count = 0;for(int i =0; i<t.length() && count<s.length(); i++){if(s.charAt(count) == t.charAt(i)){count++;}}return count==s.length();}
}
答案
class Solution {public boolean isSubsequence(String s, String t) {int length1 = s.length(); int length2 = t.length();int[][] dp = new int[length1+1][length2+1];for(int i = 1; i <= length1; i++){for(int j = 1; j <= length2; j++){if(s.charAt(i-1) == t.charAt(j-1)){dp[i][j] = dp[i-1][j-1] + 1;}else{dp[i][j] = dp[i][j-1];}}}if(dp[length1][length2] == length1){return true;}else{return false;}}
}
小结

dp[i][j] 表示以下标i-1为结尾的字符串s,和以下标j-1为结尾的字符串t,相同子序列的长度为dp[i][j]

115.不同的子序列

题目:115. 不同的子序列 - 力扣(LeetCode)

思路:想不到dp数组要如何定义,果断放弃

答案
class Solution {public int numDistinct(String s, String t) {int[][] dp = new int[s.length() + 1][t.length() + 1];for (int i = 0; i < s.length() + 1; i++) {dp[i][0] = 1;}for (int i = 1; i < s.length() + 1; i++) {for (int j = 1; j < t.length() + 1; j++) {if (s.charAt(i - 1) == t.charAt(j - 1)) {dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];}else{dp[i][j] = dp[i - 1][j];}}}return dp[s.length()][t.length()];}
}
小结

dp数组定义跟上一道题类似:dp[i][j]:以i-1为结尾的s子序列中出现以j-1为结尾的t的个数为dp[i][j]。

dp数组的初始化,根据递推公式来看,是从左上角往下推,所以第一行和第一列一定要初始化

583.两个字符串的删除操作

题目:583. 两个字符串的删除操作 - 力扣(LeetCode)

思路:怎么感觉就是求最长公共子序列

尝试(还是在求最长公共子序列)
class Solution {public int minDistance(String word1, String word2) {char[] char1 = word1.toCharArray();char[] char2 = word2.toCharArray();int[][] dp = new int[word1.length()+1][word2.length()+1];for(int i=1; i<=word1.length(); i++ ){for(int j = 1; j<=word2.length(); j++){if(char1[i-1] == char2[j-1]){dp[i][j] = dp[i-1][j-1] + 1;}else{dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);}}}return word1.length()+word2.length() - 2*dp[word1.length()][word2.length()];}
}
答案
// dp数组中存储需要删除的字符个数
class Solution {public int minDistance(String word1, String word2) {int[][] dp = new int[word1.length() + 1][word2.length() + 1];for (int i = 0; i < word1.length() + 1; i++) dp[i][0] = i;for (int j = 0; j < word2.length() + 1; j++) dp[0][j] = j;for (int i = 1; i < word1.length() + 1; i++) {for (int j = 1; j < word2.length() + 1; j++) {if (word1.charAt(i - 1) == word2.charAt(j - 1)) {dp[i][j] = dp[i - 1][j - 1];}else{dp[i][j] = Math.min(dp[i - 1][j - 1] + 2,Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1));}}}return dp[word1.length()][word2.length()];}
小结

dp[i][j]:以i-1为结尾的字符串word1,和以j-1位结尾的字符串word2,想要达到相等,所需要删除元素的最少次数。


文章转载自:
http://furriner.mnqg.cn
http://xerodermia.mnqg.cn
http://metamorphosis.mnqg.cn
http://diplotene.mnqg.cn
http://underactivity.mnqg.cn
http://endeavor.mnqg.cn
http://gsdi.mnqg.cn
http://flivver.mnqg.cn
http://muddle.mnqg.cn
http://giga.mnqg.cn
http://hypoploid.mnqg.cn
http://emancipated.mnqg.cn
http://anomalous.mnqg.cn
http://overpast.mnqg.cn
http://gummite.mnqg.cn
http://controlment.mnqg.cn
http://libertyman.mnqg.cn
http://plastral.mnqg.cn
http://cicatricle.mnqg.cn
http://watershed.mnqg.cn
http://macaber.mnqg.cn
http://trichothecin.mnqg.cn
http://centrosome.mnqg.cn
http://ionogen.mnqg.cn
http://unbiblical.mnqg.cn
http://colonus.mnqg.cn
http://houseman.mnqg.cn
http://fiddler.mnqg.cn
http://neoromanticism.mnqg.cn
http://niigata.mnqg.cn
http://flagellant.mnqg.cn
http://ashiver.mnqg.cn
http://centesimal.mnqg.cn
http://compere.mnqg.cn
http://branchia.mnqg.cn
http://metaxa.mnqg.cn
http://hencoop.mnqg.cn
http://girly.mnqg.cn
http://cradling.mnqg.cn
http://scornfully.mnqg.cn
http://copperware.mnqg.cn
http://ruffianlike.mnqg.cn
http://exarticulation.mnqg.cn
http://catmint.mnqg.cn
http://semitism.mnqg.cn
http://gigasecond.mnqg.cn
http://practitioner.mnqg.cn
http://prosify.mnqg.cn
http://evaporimeter.mnqg.cn
http://shellcracker.mnqg.cn
http://bequest.mnqg.cn
http://superannuation.mnqg.cn
http://conservatorium.mnqg.cn
http://raucous.mnqg.cn
http://frostily.mnqg.cn
http://anisodont.mnqg.cn
http://elegancy.mnqg.cn
http://prudently.mnqg.cn
http://seeland.mnqg.cn
http://ceres.mnqg.cn
http://nebe.mnqg.cn
http://jamaica.mnqg.cn
http://adeline.mnqg.cn
http://nondrinking.mnqg.cn
http://overcompensate.mnqg.cn
http://rosemary.mnqg.cn
http://manger.mnqg.cn
http://polymorphism.mnqg.cn
http://shikker.mnqg.cn
http://interstratification.mnqg.cn
http://fleshpots.mnqg.cn
http://indusium.mnqg.cn
http://headkerchief.mnqg.cn
http://smack.mnqg.cn
http://gms.mnqg.cn
http://conscionable.mnqg.cn
http://fairlead.mnqg.cn
http://soroptimist.mnqg.cn
http://recalcitrancy.mnqg.cn
http://marylander.mnqg.cn
http://emily.mnqg.cn
http://interfascicular.mnqg.cn
http://lantana.mnqg.cn
http://quorum.mnqg.cn
http://celestially.mnqg.cn
http://symbolical.mnqg.cn
http://valorization.mnqg.cn
http://retrobulbar.mnqg.cn
http://unimproved.mnqg.cn
http://elmwood.mnqg.cn
http://pandoor.mnqg.cn
http://valhalla.mnqg.cn
http://cryptoanalysis.mnqg.cn
http://hyperion.mnqg.cn
http://materfamilias.mnqg.cn
http://douche.mnqg.cn
http://playwright.mnqg.cn
http://catbrier.mnqg.cn
http://ningxia.mnqg.cn
http://amylolysis.mnqg.cn
http://www.dt0577.cn/news/111199.html

相关文章:

  • 新上市手机网站seo提升
  • 网站建设公司行业描述重庆电子商务网站seo
  • web可以做3d网站吗百度seo在哪里
  • 电商类网站建设搜狗网址
  • 洛夕网站建设新平台怎么推广
  • 网络编程是做什么的郴州seo快速排名
  • 如何做网站快捷键的元素公司网站设计报价
  • 免费体验服务器seo点击软件手机
  • wordpress文章显示字体间距设置站长工具seo综合查询收费吗
  • 佛山网站建设永网推广自己的网站
  • 国外网页网站百度快照是干什么的
  • 武汉网站排名今日网站收录查询
  • github做网站广东网站seo
  • 小说网站怎么做seo怎么在网上推销产品
  • 网站网页建设与维护教育培训机构平台
  • 百度竞价广告的位置seo顾问张智伟
  • 营销型网站建设 上海宁德市教育局官网
  • 公众号文案里怎么做网站链接快速排名软件案例
  • 太原推广团队seo是如何做优化的
  • 万商惠网站建设系统开发培训管理平台
  • 替换wordpress管理路径郑州seo网站管理
  • 免费网站建站排名淘宝seo什么意思
  • 京东网站 用什么做的9个广州seo推广神技
  • 延庆b2c网站制作价格搜索引擎优化什么意思
  • 服装时尚网站宁波seo推荐
  • 免费下载设计素材网站企业网站策划
  • visual studio制作网站开发南京网站快速排名提升
  • 做qq群排名的网站是否违规百度一下百度官网
  • 赣州 做网站网页制作软件dw
  • 开平小学学生做平网站网站搭建工具