博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Distinct Subsequences 动态规划 没有太看懂的一题(重重重)-----重看
阅读量:4107 次
发布时间:2019-05-25

本文共 677 字,大约阅读时间需要 2 分钟。

题目:

解答:

没有太看懂 看了网上的一些资料

http://www.cnblogs.com/ganganloveu/p/3836519.html

代码:

class Solution {public:    int numDistinct(string S, string T)     {        int m = S.size();        int n = T.size();        vector
> transArr(m+1, vector
(n+1, 0)); for(int i = 0; i < m+1; i ++) transArr[i][0] = 1; for(int i = 1; i < m+1; i ++) { for(int j = 1; j < n+1; j ++) { if(S[i-1] == T[j-1]) transArr[i][j] = transArr[i-1][j-1]+transArr[i-1][j]; else transArr[i][j] = transArr[i-1][j]; } } return transArr[m][n]; }};

你可能感兴趣的文章
Binary Tree Maximum Path Sum 自底向上求解(重重重重)
查看>>
Subsets 深搜
查看>>
Subsets II
查看>>
Edit Distance 字符串距离(重重)
查看>>
Gray Code 格雷码
查看>>
对话周鸿袆:从程序员创业谈起
查看>>
web.py 0.3 新手指南 - 如何用Gmail发送邮件
查看>>
web.py 0.3 新手指南 - 实时语言切换
查看>>
web.py 0.3 新手指南 - RESTful doctesting using app.request
查看>>
web.py 0.3 新手指南 - 使用db.query进行高级数据库查询
查看>>
web.py 0.3 新手指南 - 多数据库使用
查看>>
一步步开发 Spring MVC 应用
查看>>
python: extend (扩展) 与 append (追加) 的差别
查看>>
「译」在 python 中,如果 x 是 list,为什么 x += "ha" 可以运行,而 x = x + "ha" 却抛出异常呢?...
查看>>
谷歌阅读器将于2013年7月1日停止服务,博客订阅转移到邮箱
查看>>
浅谈JavaScript的语言特性
查看>>
Hid Report Descriptor
查看>>
strlen,strcpy,strcat,strcmp,strstr各代表什么意思
查看>>
手机GPRS、短信等设置
查看>>
结构体声明
查看>>