https://leetcode.com/problems/distinct-subsequences/

Given a string S and a string T, count the number of distinct subsequences of T in S.

A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, `"ACE"` is a subsequence of `"ABCDE"` while `"AEC"` is not).

Here is an example:
S = `"rabbbit"`, T = `"rabbit"`

Return `3`.

f[i][j]=f[i-1][j]+[i-1][j-1]。

```int numDistinct(string s, string t) {
int m=s.size();
int n=t.size();

vector<vector<,vector<,));

;i<=m;i++)
{
;j<=n;j++)
{
&& j==)
f[i][j]=;
)
f[i][j]=;
)
f[i][j]=;
else
f[i][j]=f[i-][j]+(s[i-]==t[j-]?f[i-][j-]:);
}
}
return f[m][n];
}```

## Distinct Subsequences的更多相关文章

1. [LeetCode] Distinct Subsequences 不同的子序列

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

2. Leetcode Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

3. LeetCode（115） Distinct Subsequences

题目 Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequen ...

4. [Leetcode][JAVA] Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

5. Distinct Subsequences Leetcode

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

6. 【leetcode】Distinct Subsequences(hard)

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

7. 【LeetCode OJ】Distinct Subsequences

Problem Link: http://oj.leetcode.com/problems/distinct-subsequences/ A classic problem using Dynamic ...

8. LeetCode 笔记22 Distinct Subsequences 动态规划需要冷静

Distinct Subsequences Given a string S and a string T, count the number of distinct subsequences of  ...

9. leetcode 115 Distinct Subsequences ----- java

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

## 随机推荐

1. 在html中关于如果function的函数名和input的name一样会发生怎样的现象

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="2_PageMethods. ...

2. JQuery选择器中含有冒号的ID处理差异的分析

问题提出 对于一个输入框, 如果其id中含有冒号(:),选择器使用需要有特殊写法, 例如 id为下 <input type="text" value="ddd&qu ...

3. SSL协议运行机制

SSL/TLS协议运行机制 一.作用 不使用SSL/TLS的HTTP通信,就是不加密的通信.所有信息明文传播,带来了三大风险. (1) 窃听风险(eavesdropping):第三方可以获知通信内容. ...

4. java int和String类型之间的相互转换

String --> int 第一种方法:int i = Integer.parseInt(s); 第二种方法:int i = Integer.valueOf(s).intValue(); 两种 ...

5. Authentication with SignalR and OAuth Bearer Token

Authentication with SignalR and OAuth Bearer Token Authenticating connections to SignalR is not as e ...

6. Web2py也有意思的

多学学,以后可以方便的自己写代码了. 对于各种WEB框架,这也是打一个基础的时候. 相信学入门了,对PHP的,JAVA的WEB框架,都是能理解更深入的. def index(): "&quo ...

7. TCP粘包的拆包处理

因为TCP是流式处理的,所以包没有边界,必须设计一个包头,里面表示包的长度(一般用字节表示),根据这个来逐个拆包.如果对于发送/接收频率不高的话,一般也就不做拆包处理了,因为不大可能有粘包现象. 以下 ...

8. iOS 横屏模态进入下一级界面, 竖屏退出

首先  Deployment Info 设置 除了  Upside Down 都勾选 然后,在AppDelegate.h 文件中 添加属性 @property(nonatomic,assign)NSI ...

9. keras如何求分类问题中的准确率和召回率

https://www.zhihu.com/question/53294625 由于要用keras做一个多分类的问题,评价标准采用precision,recall,和f1_score:但是keras中 ...

10. Ubuntu 16.04 中安装谷歌 Chrome 浏览器