摘要:
动态规划 class Solution { public int longestPalindromeSubseq(String s) { /** * 类似于《647. 回文子串》 * dp[i][j]定义为区间为[i, j]内最长的回文子串长度 * 初始化每个字符就是一个回文串,即每个dp[i][i 阅读全文
posted @ 2022-03-04 18:06
振袖秋枫问红叶
阅读(44)
评论(0)
推荐(0)
摘要:
动态规划 class Solution { public int minDistance(String word1, String word2) { /** * 和《583. 两个字符串的删除操作》一模一样 * 只有一个地方不一样 */ int[][] dp = new int[word1.leng 阅读全文
posted @ 2022-03-04 17:17
振袖秋枫问红叶
阅读(33)
评论(0)
推荐(0)
摘要:
动态规划 class Solution { public int minDistance(String word1, String word2) { /** * dp[i][j]定义为以word1[i - 1]结尾的字符串,和以word2[j - 1]结尾的字符串,要想相等需要删除的最小元素个数 * 阅读全文
posted @ 2022-03-04 17:04
振袖秋枫问红叶
阅读(65)
评论(0)
推荐(0)
摘要:
动态规划 class Solution { public int numDistinct(String s, String t) { /** * 结合《1143. 最长公共子序列》和《392. 判断子序列》 * dp[i][j]定义为以s[i - 1]结尾的字符串s中出现以t[j - 1]结尾的字符 阅读全文
posted @ 2022-03-04 16:44
振袖秋枫问红叶
阅读(46)
评论(0)
推荐(0)
摘要:
完全背包 import java.util.List; class Solution { public boolean wordBreak(String s, List<String> wordDict) { /** * dp[j]定义为长度为j的字符串是否可以由字典中的子串组成,即[0, j - 阅读全文
posted @ 2022-03-04 15:11
振袖秋枫问红叶
阅读(38)
评论(0)
推荐(0)

浙公网安备 33010602011771号