title: Total Number Of Non Decreasing Numbers With N Digits
signature: class Solution {
  
      public Long totalNumberOfNonDecreasingNumbersWithNDigits(Integer n) {
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(21, 14307150L);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(40, 2054455634L);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(83, 868754947060L);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(93, 2290415157800L);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(43, 3679075400L);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(98, 3585446225075L);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(35, 708930508L);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(86, 1174992339235L);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(76, 411731930610L);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(88, 1429144287220L);
          System.out.println(String.format("%s%s","TEST-9...",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
source_py: def total_number_of_non_decreasing_numbers_with_n_digits(n):
      dp = [[0 for i in range((n + 1))] for i in range(10)]
      for i in range(10):
          dp[i][1] = 1
      for digit in range(10):
          for len in range(2, (n + 1)):
              for x in range((digit + 1)):
                  dp[digit][len] += dp[x][(len - 1)]
      count = 0
      for i in range(10):
          count += dp[i][n]
      return count
source_cpp: long long int total_number_of_non_decreasing_numbers_with_n_digits(int n) {
    long long int dp [ 10 ] [ n + 1 ];
    memset ( dp, 0, sizeof dp );
    for ( int i = 0;
    i < 10;
    i ++ ) dp [ i ] [ 1 ] = 1;
    for ( int digit = 0;
    digit <= 9;
    digit ++ ) {
      for ( int len = 2;
      len <= n;
      len ++ ) {
        for ( int x = 0;
        x <= digit;
        x ++ ) dp [ digit ] [ len ] += dp [ x ] [ len - 1 ];
      }
    }
    long long int count = 0;
    for ( int i = 0;
    i < 10;
    i ++ ) count += dp [ i ] [ n ];
    return count;
  }