zoukankan      html  css  js  c++  java
  • LeetCode Distinct Subsequences

     //  136ms 过大的
    1
    int f[100][11000]; 2 class Solution { 3 public: 4 int numDistinct(string S, string T) { 5 // Start typing your C/C++ solution below 6 // DO NOT write int main() function 7 memset(f,0,100*11000); 8 9 int i,j; 10 const char *s=S.c_str(); 11 const char *t=T.c_str(); 12 for(i=0;i<11000;i++) 13 { 14 f[0][i]=1; 15 } 16 17 for(i=0;t[i];i++) 18 { 19 for(j=0;s[j];j++) 20 { 21 if(t[i]==s[j]) 22 { 23 f[i+1][j+1]=f[i+1][j]+f[i][j]; 24 } 25 else 26 { 27 f[i+1][j+1]=f[i+1][j]; 28 } 29 } 30 } 31 return f[i][j]; 32 } 33 };
  • 相关阅读:
    poj3255,poj2449
    poj2186
    poj3249
    poj3378
    poj3274
    poj1948
    hdu 2181暴搜
    hdu 3342
    hdu 1285
    hdu 1598
  • 原文地址:https://www.cnblogs.com/mengqingzhong/p/3117365.html
Copyright © 2011-2022 走看看