title: Find Number Times String Occurs Given String 1
signature: function find_number_times_string_occurs_given_string_1(a, b)
source_py: def find_number_times_string_occurs_given_string_1(a, b):
      m = len(a)
      n = len(b)
      lookup = [([0] * (n + 1)) for i in range((m + 1))]
      for i in range((n + 1)):
          lookup[0][i] = 0
      for i in range((m + 1)):
          lookup[i][0] = 1
      for i in range(1, (m + 1)):
          for j in range(1, (n + 1)):
              if (a[(i - 1)] == b[(j - 1)]):
                  lookup[i][j] = (lookup[(i - 1)][(j - 1)] + lookup[(i - 1)][j])
              else:
                  lookup[i][j] = lookup[(i - 1)][j]
      return lookup[m][n]
source_cpp: int find_number_times_string_occurs_given_string_1(string a, string b) {
    int m = a . length ( );
    int n = b . length ( );
    int lookup [ m + 1 ] [ n + 1 ] = {
      {
        0 }
      };
      for ( int i = 0;
      i <= n;
      ++ i ) lookup [ 0 ] [ i ] = 0;
      for ( int i = 0;
      i <= m;
      ++ i ) lookup [ i ] [ 0 ] = 1;
      for ( int i = 1;
      i <= m;
      i ++ ) {
        for ( int j = 1;
        j <= n;
        j ++ ) {
          if ( a [ i - 1 ] == b [ j - 1 ] ) lookup [ i ] [ j ] = lookup [ i - 1 ] [ j - 1 ] + lookup [ i - 1 ] [ j ];
          else lookup [ i ] [ j ] = lookup [ i - 1 ] [ j ];
        }
      }
      return lookup [ m ] [ n ];
    }
question_info.entry_fn_name: find_number_times_string_occurs_given_string_1
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(a, b, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, b) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver("fZOKCdZ Lav", "fKA", 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver("2", "187012", 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver("1000001110", "0", 6)
      print(string.format("TEST-2...%s",result))
  
      result = driver("IAOyBzgIWHo", "oA", 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver("211806", "10", 2)
      print(string.format("TEST-4...%s",result))
  
      result = driver("1", "001011100", 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver("CVaQTG", "CT", 1)
      print(string.format("TEST-6...%s",result))
  
      result = driver("6265187228", "628", 6)
      print(string.format("TEST-7...%s",result))
  
      result = driver("10111101101000", "01111", 35)
      print(string.format("TEST-8...%s",result))
  
      result = driver("vEi", "bigsvkQG", 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"a": "fZOKCdZ Lav", "b": "fKA"}}, {"idx": 1, "outputs": 0, "inputs": {"a": "2", "b": "187012"}}, {"idx": 2, "outputs": 6, "inputs": {"a": "1000001110", "b": "0"}}, {"idx": 3, "outputs": 0, "inputs": {"a": "IAOyBzgIWHo", "b": "oA"}}, {"idx": 4, "outputs": 2, "inputs": {"a": "211806", "b": "10"}}, {"idx": 5, "outputs": 0, "inputs": {"a": "1", "b": "001011100"}}, {"idx": 6, "outputs": 1, "inputs": {"a": "CVaQTG", "b": "CT"}}, {"idx": 7, "outputs": 6, "inputs": {"a": "6265187228", "b": "628"}}, {"idx": 8, "outputs": 35, "inputs": {"a": "10111101101000", "b": "01111"}}, {"idx": 9, "outputs": 0, "inputs": {"a": "vEi", "b": "bigsvkQG"}}]