title: Ways Transforming One String Removing 0 Characters
signature: class Solution {
  
      public int WaysTransformingOneStringRemoving0Characters(string a, string b) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(string a, string b, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(a, b); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  "abcccdf", "abccdf", 
                  3
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  "aabba", "ab", 
                  4
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  "aabsdfljk", "aa", 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  "IONiqV", "XKbBiGZ", 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  "9667771256770", "50915176", 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  "10001011", "01", 
                  11
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  "fczbDtMDT", "FbX", 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  "298746088", "29888", 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  "01100011000", "0", 
                  7
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  "Qk", "", 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def ways_transforming_one_string_removing_0_characters(a, b):
      n = len(a)
      m = len(b)
      if (m == 0):
          return 1
      dp = [([0] * (n + 1)) for _ in range((m + 1))]
      for i in range(m):
          for j in range(i, n):
              if (i == 0):
                  if (j == 0):
                      if (a[j] == b[i]):
                          dp[i][j] = 1
                      else:
                          dp[i][j] = 0
                  elif (a[j] == b[i]):
                      dp[i][j] = (dp[i][(j - 1)] + 1)
                  else:
                      dp[i][j] = dp[i][(j - 1)]
              elif (a[j] == b[i]):
                  dp[i][j] = (dp[i][(j - 1)] + dp[(i - 1)][(j - 1)])
              else:
                  dp[i][j] = dp[i][(j - 1)]
      return dp[(m - 1)][(n - 1)]
source_cpp: int ways_transforming_one_string_removing_0_characters(string a, string b) {
    int n = a . size ( ), m = b . size ( );
    if ( m == 0 ) return 1;
    int dp [ m + 1 ] [ n + 1 ];
    memset ( dp, 0, sizeof ( dp ) );
    for ( int i = 0;
    i < m;
    i ++ ) {
      for ( int j = i;
      j < n;
      j ++ ) {
        if ( i == 0 ) {
          if ( j == 0 ) dp [ i ] [ j ] = ( a [ j ] == b [ i ] ) ? 1 : 0;
          else if ( a [ j ] == b [ i ] ) dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + 1;
          else dp [ i ] [ j ] = dp [ i ] [ j - 1 ];
        }
        else {
          if ( a [ j ] == b [ i ] ) dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j - 1 ];
          else dp [ i ] [ j ] = dp [ i ] [ j - 1 ];
        }
      }
    }
    return dp [ m - 1 ] [ n - 1 ];
  }