title: Ways Transforming One String Removing 0 Characters
signature: int waysTransformingOneStringRemoving0Characters(string a, string b) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(string a, string b, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(a, b), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver("abcccdf", "abccdf", 3); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver("aabba", "ab", 4); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver("aabsdfljk", "aa", 1); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver("IONiqV", "XKbBiGZ", 0); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver("9667771256770", "50915176", 0); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver("10001011", "01", 11); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver("fczbDtMDT", "FbX", 0); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver("298746088", "29888", 1); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver("01100011000", "0", 7); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver("Qk", "", 1); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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 ];
  }