可以定义dp[i][j]表示第一个串的前i个字符中含有第二个串的前j个字符的总情况数;
则:如dp[i][j]=dp[i-1][j],如果str1[i]==str2[j]则dp[i][j]+=dp[i-1][j-1];
初始时讲所有的dp[i][0]赋值为1,其他为0。
然后这个题目需要用到大数,可以用C++重载运算符,或者是java的大数类;
我用的是java,第一次用java的大数,感...
分类:
其他好文 时间:
2015-01-27 16:20:39
阅读次数:
161
题目链接:点击打开链接
Description
Give a positive number, count the sum of the distinct subsequence of it, moreover, any subsequence should not contain leading zeroes except it is zero.
...
分类:
其他好文 时间:
2015-01-24 20:08:06
阅读次数:
240
Problem:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from ...
分类:
其他好文 时间:
2015-01-24 15:44:24
阅读次数:
179
题目链接:点击打开链接
题意:
给定一个长整数
求所有不同的子序列和。
思路:
dp[i]表示以i数字为结尾的序列的和
num[i]表示以i数字为结尾的序列个数
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
i...
分类:
其他好文 时间:
2015-01-23 20:10:12
阅读次数:
164
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
其他好文 时间:
2015-01-22 19:53:56
阅读次数:
168
Distinct SubsequencesGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is...
分类:
其他好文 时间:
2015-01-20 15:07:57
阅读次数:
164
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
编程语言 时间:
2015-01-09 06:56:19
阅读次数:
239
问题描述:
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...
分类:
其他好文 时间:
2015-01-05 21:58:33
阅读次数:
185
不知不觉居然已经写了200多篇随笔了,现在查找的时候经常要翻好久,很不方便。故给自己做个目录~Leetcode1、动态规划Palindrome Partitioning II(hard) ☆Distinct Subsequences(hard)Edit Distance (hard)Interlea...
分类:
其他好文 时间:
2015-01-02 14:32:34
阅读次数:
183
题目:(DP)Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from t...
分类:
其他好文 时间:
2015-01-02 10:55:22
阅读次数:
120