摘要: 动态规划 class Solution { public int countSubstrings(String s) { /** * dp[i][j]定义为区间为[i, j]的子串是否是回文串 */ boolean[][] dp = new boolean[s.length()][s.length( 阅读全文
posted @ 2022-03-01 13:02 振袖秋枫问红叶 阅读(39) 评论(0) 推荐(0)
摘要: 动态规划 class Solution { public boolean isSubsequence(String s, String t) { /** * 和《1143. 最长公共子序列》一样 */ int[][] dp = new int[s.length() + 1][t.length() + 阅读全文
posted @ 2022-03-01 10:31 振袖秋枫问红叶 阅读(31) 评论(0) 推荐(0)
摘要: 动态规划 class Solution { public int maxUncrossedLines(int[] nums1, int[] nums2) { /** * 和《1143. 最长公共子序列》一样 */ int[][] dp = new int[nums1.length + 1][nums 阅读全文
posted @ 2022-03-01 09:59 振袖秋枫问红叶 阅读(29) 评论(0) 推荐(0)
摘要: 动态规划 class Solution { public int longestCommonSubsequence(String text1, String text2) { /** * dp[i][j]定义为text1[i - 1] == text2[j - 1]时的公共子序列的最大长度 */ i 阅读全文
posted @ 2022-03-01 09:52 振袖秋枫问红叶 阅读(27) 评论(0) 推荐(0)