<awangdev>Distinct Subsequences_2.java
public int numDistinct(String s, String t) {
        if (s == null || t == null || t.length() > s.length()) {
            return 0;
        } else if (s.equals(t)) {
            return 1;
        }
        
        int m = s.length();
        int n = t.length();
        int[][] dp = new int[2][n + 1];
        int curr = 0;
        int prev = 0;
        for (int i = 0; i <= m; i++) {
            prev = curr;
            curr = 1 - prev;
            for (int j = 0; j <= n; j++) {
                if (j == 0) {
                    dp[curr][j] = 1;
                    continue;
                }
                if (i == 0) {
                    dp[curr][j] = 0;
                    continue;
                }
                dp[curr][j] = dp[prev][j];
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                   dp[curr][j] += dp[prev][j - 1];
                }
            }
        }
        return dp[curr][n];
    }
public int sample_funcname ( String var_1 , String var_2 ) {
  if ( var_1 == null || var_2 == null || var_2 . length ( ) > var_1 . length ( ) ) {
    return 0 ;
  }
  else if ( var_1 . equals ( var_2 ) ) {
    return 1 ;
  }
  int var_8 = var_1 . length ( ) ;
  int var_9 = var_2 . length ( ) ;
  int [ ] [ ] var_11 = new int [ 2 ] [ var_9 + 1 ] ;
  int var_12 = 0 ;
  int var_13 = 0 ;
  for ( int var_14 = 0 ;
  var_14 <= var_8 ;
  var_14 ++ ) {
    var_13 = var_12 ;
    var_12 = 1 - var_13 ;
    for ( int var_15 = 0 ;
    var_15 <= var_9 ;
    var_15 ++ ) {
      if ( var_15 == 0 ) {
        var_11 [ var_12 ] [ var_15 ] = 1 ;
        continue ;
      }
      if ( var_14 == 0 ) {
        var_11 [ var_12 ] [ var_15 ] = 0 ;
        continue ;
      }
      var_11 [ var_12 ] [ var_15 ] = var_11 [ var_13 ] [ var_15 ] ;
      if ( var_1 . charAt ( var_14 - 1 ) == var_2 . charAt ( var_15 - 1 ) ) {
        var_11 [ var_12 ] [ var_15 ] += var_11 [ var_13 ] [ var_15 - 1 ] ;
      }
    }
  }
  return var_11 [ var_12 ] [ var_9 ] ;
}
