115. Distinct Subsequences

Posted 鸵鸟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了115. Distinct Subsequences相关的知识,希望对你有一定的参考价值。

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

  

以上是关于115. Distinct Subsequences的主要内容,如果未能解决你的问题,请参考以下文章

115. Distinct Subsequences

115. Distinct Subsequences

115. Distinct Subsequences(js)

leetcode1081. Smallest Subsequence of Distinct Characters

算法: 不同的子序列115. Distinct Subsequences

115. Distinct Subsequences