title: Count Possible Paths Top Left Bottom Right Nxm Matrix 2
signature: function countPossiblePathsTopLeftBottomRightNxmMatrix2(p, q) {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value) {
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual, expected){
      return convertToString(actual)===convertToString(expected);
  }
  
  function driver(p, q, expected){
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(p, q),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(70, 5, 1088430);
    console.log(`TEST-0...${result}`);
  
    result = driver(9, 59, 5743572120);
    console.log(`TEST-1...${result}`);
  
    result = driver(54, 1, 1);
    console.log(`TEST-2...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    main();
  }
source_py: def count_possible_paths_top_left_bottom_right_nxm_matrix_2(p, q):
      dp = [1 for i in range(q)]
      for i in range((p - 1)):
          for j in range(1, q):
              dp[j] += dp[(j - 1)]
      return dp[(q - 1)]
source_cpp: int count_possible_paths_top_left_bottom_right_nxm_matrix_2(int m, int n) {
    int dp [ n ] = {
      1 };
      dp [ 0 ] = 1;
      for ( int i = 0;
      i < m;
      i ++ ) {
        for ( int j = 1;
        j < n;
        j ++ ) {
          dp [ j ] += dp [ j - 1 ];
        }
      }
      return dp [ n - 1 ];
    }