Day 57|647. 回文子串| 516.最长回文子序列

● 647. 回文子串
class Solution {
    public int countSubstrings(String s) {
   char[] chars = s.toCharArray();
   int len = chars.length;
   boolean[][] dp = new boolean[len][len];
   int result = 0;
   for(int i = len-1;i>=0;i--){
       for(int j =i;j 
  

● 516.最长回文子序列

class Solution {
    public int longestPalindromeSubseq(String s) {
    int len = s.length();
    int[][] dp = new int[len+1][len+1];
    for(int i = len-1;i>=0;i--){
        dp[i][i] = 1;
        for(int j = i+1;j 
  

● 动态规划总结篇

你可能感兴趣的:(算法,leetcode)