title: Number N Digit Stepping Numbers
signature: class Solution {
  
      public Long numberNDigitSteppingNumbers(Integer n) {
source_py: def number_n_digit_stepping_numbers(n):
      dp = [[0 for x in range(10)] for y in range((n + 1))]
      if (n == 1):
          return 10
      for j in range(10):
          dp[1][j] = 1
      for i in range(2, (n + 1)):
          for j in range(10):
              if (j == 0):
                  dp[i][j] = dp[(i - 1)][(j + 1)]
              elif (j == 9):
                  dp[i][j] = dp[(i - 1)][(j - 1)]
              else:
                  dp[i][j] = (dp[(i - 1)][(j - 1)] + dp[(i - 1)][(j + 1)])
      sum = 0
      for j in range(1, 10):
          sum = (sum + dp[n][j])
      return sum
source_cpp: long long number_n_digit_stepping_numbers(int n) {
    int dp [ n + 1 ] [ 10 ];
    if ( n == 1 ) return 10;
    for ( int j = 0;
    j <= 9;
    j ++ ) dp [ 1 ] [ j ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      for ( int j = 0;
      j <= 9;
      j ++ ) {
        if ( j == 0 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j + 1 ];
        else if ( j == 9 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ];
        else dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] + dp [ i - 1 ] [ j + 1 ];
      }
    }
    long long sum = 0;
    for ( int j = 1;
    j <= 9;
    j ++ ) sum += dp [ n ] [ j ];
    return sum;
  }
question_info.extension: java
question_info.entry_fn_name: numberNDigitSteppingNumbers
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 547810, "inputs": {"n": 18}}, {"idx": 1, "outputs": 100719775, "inputs": {"n": 26}}, {"idx": 2, "outputs": 1774846161206, "inputs": {"n": 41}}, {"idx": 3, "outputs": 2017126, "inputs": {"n": 20}}, {"idx": 4, "outputs": 52479500, "inputs": {"n": 25}}, {"idx": 5, "outputs": 2306507126768895, "inputs": {"n": 52}}, {"idx": 6, "outputs": 21053, "inputs": {"n": 13}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Long expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(18, 547810L);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(26, 100719775L);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(41, 1774846161206L);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(20, 2017126L);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(25, 52479500L);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(52, 2306507126768895L);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(13, 21053L);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Long expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Long actual, Long expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6
question_info.commands: java __FILENAME__