public static int numDistinct(String s, String t) {
        if (s.length() == 0 || t.length() == 0)
            return 0;
        int[][] dp = new int[t.length() + 1][s.length() + 1];
        for (int i = 0; i <= s.length(); ++i)
            dp[0][i] = 1;
        for (int i = 1; i <= t.length(); ++i) {
            for (int j = 1; j <= s.length(); ++j) {
                dp[i][j] = dp[i][j - 1];
                if (s.charAt(j - 1) == t.charAt(i - 1))
                    dp[i][j] += dp[i - 1][j - 1];
            }
        }
        for (int[] row : dp) {
            for (int i : row) {
                System.out.print(i + " ");
            }
            System.out.println();
        }
        return dp[t.length()][s.length()];
    }