title: Find Number Times String Occurs Given String 1
signature: class Solution {
  
      public Integer findNumberTimesStringOccursGivenString1(String a, String b) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String a, String b, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, b,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("fZOKCdZ Lav", "fKA", 0);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("2", "187012", 0);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("1000001110", "0", 6);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("IAOyBzgIWHo", "oA", 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("211806", "10", 2);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("1", "001011100", 0);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("CVaQTG", "CT", 1);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("6265187228", "628", 6);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("10111101101000", "01111", 35);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("vEi", "bigsvkQG", 0);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String a, String b, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, b),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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 ];
    }