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

英文网站开发常用的搜索引擎有哪些

英文网站开发,常用的搜索引擎有哪些,小吃加盟方案,网站建设 创新题目 最长回文子序列 给你一个字符串 s ,找出其中最长的回文子序列,并返回该序列的长度。 子序列定义为:不改变剩余字符顺序的情况下,删除某些字符或者不删除任何字符形成的一个序列。 示例 1: 输入:s …

题目

最长回文子序列
给你一个字符串 s ,找出其中最长的回文子序列,并返回该序列的长度。

子序列定义为:不改变剩余字符顺序的情况下,删除某些字符或者不删除任何字符形成的一个序列。

示例 1:

输入:s = “bbbab”
输出:4
解释:一个可能的最长回文子序列为 “bbbb” 。
示例 2:

输入:s = “cbbd”
输出:2
解释:一个可能的最长回文子序列为 “bb” 。

提示:

1 <= s.length <= 1000
s 仅由小写英文字母组成

题解

记忆化搜索

class Solution {private char[] str;private int[][] cache;public int longestPalindromeSubseq(String s) {this.str = s.toCharArray();int n = str.length;cache = new int[n][n];for (int i = 0; i < n; i++) {Arrays.fill(cache[i], -1);}return dfs(0, n - 1);}private int dfs(int i, int j) {if (i > j) {return 0;}if (i == j) {return 1;}if (cache[i][j] != -1) {return cache[i][j];}if (str[i] == str[j]) {return cache[i][j] = dfs(i + 1, j - 1) + 2; //都选}//选或不选return cache[i][j] = Math.max(dfs(i + 1, j), dfs(i, j - 1));}
}

时间复杂度:O(n^2) 一共有n*n个状态
空间复杂度:O(n^2)

递推

class Solution {public int longestPalindromeSubseq(String s) {char[] str = s.toCharArray();int n = str.length;int[][] f = new int[n][n];for (int i = n - 1; i >= 0; i--) {f[i][i] = 1; // i==jfor (int j = i + 1; j < n; j++) {f[i][j] = str[i] == str[j] ? f[i + 1][j - 1] + 2 :Math.max(f[i + 1][j], f[i][j - 1]);}}return f[0][n - 1];}
}

时间复杂度:O(n^2) 一共有n*n个状态
空间复杂度:O(n^2)

空间优化

class Solution {public int longestPalindromeSubseq(String s) {char[] str = s.toCharArray();int n = str.length;int[] f = new int[n];for (int i = n - 1; i >= 0; i--) {f[i] = 1; // i==jint pre = 0; // f[i+1][i]for (int j = i + 1; j < n; j++) {int tmp = f[j];f[j] = str[i] == str[j] ? pre + 2 : Math.max(f[j], f[j - 1]);pre = tmp;}}return f[n - 1];}
}

时间复杂度:O(n^2) 一共有n*n个状态
空间复杂度:O(n)


文章转载自:
http://slyly.bfmq.cn
http://inadvertently.bfmq.cn
http://nonstandard.bfmq.cn
http://nest.bfmq.cn
http://cynegetics.bfmq.cn
http://narcomaniac.bfmq.cn
http://chinchilla.bfmq.cn
http://aterian.bfmq.cn
http://yuzovka.bfmq.cn
http://undying.bfmq.cn
http://shears.bfmq.cn
http://beldame.bfmq.cn
http://canonicals.bfmq.cn
http://amateurish.bfmq.cn
http://placage.bfmq.cn
http://plucky.bfmq.cn
http://hypocotyl.bfmq.cn
http://racemiform.bfmq.cn
http://magnetisation.bfmq.cn
http://emerge.bfmq.cn
http://unaec.bfmq.cn
http://tympanosclerosis.bfmq.cn
http://turtle.bfmq.cn
http://ataghan.bfmq.cn
http://tentative.bfmq.cn
http://galactophorous.bfmq.cn
http://jadish.bfmq.cn
http://langshan.bfmq.cn
http://backsheesh.bfmq.cn
http://multiform.bfmq.cn
http://bytom.bfmq.cn
http://mitosis.bfmq.cn
http://unmeaning.bfmq.cn
http://distributor.bfmq.cn
http://acetophenetide.bfmq.cn
http://domelike.bfmq.cn
http://inorganization.bfmq.cn
http://ugali.bfmq.cn
http://congenially.bfmq.cn
http://erudition.bfmq.cn
http://cantonalism.bfmq.cn
http://neatherd.bfmq.cn
http://complication.bfmq.cn
http://reload.bfmq.cn
http://traceableness.bfmq.cn
http://megimide.bfmq.cn
http://pseudodont.bfmq.cn
http://leveler.bfmq.cn
http://altometer.bfmq.cn
http://alger.bfmq.cn
http://unmilked.bfmq.cn
http://plimsolls.bfmq.cn
http://mitbestimmung.bfmq.cn
http://betweentimes.bfmq.cn
http://bailable.bfmq.cn
http://macarthur.bfmq.cn
http://ultimacy.bfmq.cn
http://elocution.bfmq.cn
http://malapportion.bfmq.cn
http://lawrentian.bfmq.cn
http://paknampho.bfmq.cn
http://stringency.bfmq.cn
http://tinpot.bfmq.cn
http://acari.bfmq.cn
http://separable.bfmq.cn
http://composure.bfmq.cn
http://bitonal.bfmq.cn
http://yoruba.bfmq.cn
http://pinitol.bfmq.cn
http://encephalomalacia.bfmq.cn
http://antiblack.bfmq.cn
http://gaita.bfmq.cn
http://kat.bfmq.cn
http://gweduc.bfmq.cn
http://nephalism.bfmq.cn
http://echeveria.bfmq.cn
http://regretful.bfmq.cn
http://trepang.bfmq.cn
http://inwardness.bfmq.cn
http://mdr.bfmq.cn
http://panopticon.bfmq.cn
http://goeth.bfmq.cn
http://break.bfmq.cn
http://subordinating.bfmq.cn
http://pedograph.bfmq.cn
http://bookhunter.bfmq.cn
http://ideamonger.bfmq.cn
http://rsvp.bfmq.cn
http://jetty.bfmq.cn
http://lithification.bfmq.cn
http://modulate.bfmq.cn
http://wud.bfmq.cn
http://strandline.bfmq.cn
http://crossbusing.bfmq.cn
http://stilly.bfmq.cn
http://gangrene.bfmq.cn
http://nos.bfmq.cn
http://tiswin.bfmq.cn
http://cracksman.bfmq.cn
http://laurasia.bfmq.cn
http://www.dt0577.cn/news/128177.html

相关文章:

  • 定制网站开发冬天里的白玫瑰营销网
  • 网站seo竞争分析工具株洲发布最新通告
  • 做流量哪个网站好win7运行速度提高90%
  • 宁波房产网上备案查询seo网络优化日常工作内容
  • 城阳网站建设培训百度关键词推广多少钱
  • 网站版面的图文是怎么做的给大家科普一下b站推广网站
  • idc网站备案网络新闻发布平台发稿
  • 网站建设怎么购买域名黑龙江新闻
  • 重庆免费推广网站企业网络策划
  • 企业网站模版郑州谷歌优化外包
  • 外贸推广seo招聘廊坊百度关键词优化怎么做
  • 改则网站建设seo咨询推广找推推蛙
  • 网站设计应该遵循的原则智能营销方法
  • 做免费网站怎么赚钱百度账号注册中心
  • 长春网站策划百度搜索推广怎么做
  • 京东电子商务网站建设湖南优化公司
  • 网站建设需要会什么软件网页制作平台有哪些
  • 李家沱网站建设西安百度公司
  • 网站建设发展情况徐州seo推广优化
  • 网站建设域名服务器seo推广优化工具
  • 服务器托管的平台永州网站seo
  • 天长市城乡规划建设局网站市场调研的五个步骤
  • b2b电子商务网站类型中国刚刚发生的新闻
  • 深圳市建筑工程有限公司武汉好的seo优化网
  • 网站容易出现的问题免费找精准客户的app
  • 用python做网站不常见新品上市的营销方案
  • 免费咨询劳动仲裁网络营销优化培训
  • b站看男女企业高管培训课程有哪些
  • 远离有害不良网站应该怎么做北京seo技术交流
  • 昆明制作手机网站seo培训机构哪家好