title: Eulerian Number 1
signature: class Solution {
  
      public Integer eulerianNumber1(Integer n, Integer m) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Integer m, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n, m,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(6, 10, 0);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(26, 33, 0);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(74, 86, 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(65, 97, 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer m, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n, m),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def eulerian_number_1(n, m):
      dp = [[0 for x in range((m + 1))] for y in range((n + 1))]
      for i in range(1, (n + 1)):
          for j in range(0, (m + 1)):
              if (i > j):
                  if (j == 0):
                      dp[i][j] = 1
                  else:
                      dp[i][j] = (((i - j) * dp[(i - 1)][(j - 1)]) + ((j + 1) * dp[(i - 1)][j]))
      return dp[n][m]
source_cpp: int eulerian_number_1(int n, int m) {
    int dp [ n + 1 ] [ m + 1 ];
    memset ( dp, 0, sizeof ( dp ) );
    for ( int i = 1;
    i <= n;
    i ++ ) {
      for ( int j = 0;
      j <= m;
      j ++ ) {
        if ( i > j ) {
          if ( j == 0 ) dp [ i ] [ j ] = 1;
          else dp [ i ] [ j ] = ( ( i - j ) * dp [ i - 1 ] [ j - 1 ] ) + ( ( j + 1 ) * dp [ i - 1 ] [ j ] );
        }
      }
    }
    return dp [ n ] [ m ];
  }