title: Minimum Steps Minimize N Per Given Condition
signature: class Solution {
  
      public Integer minimumStepsMinimizeNPerGivenCondition(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, Integer 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(59, 9);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(7, 3);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(90, 13);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(78, 11);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(49, 6);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(15, 6);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(45, 13);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(56, 6);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(7, 3);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(70, 12);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def minimum_steps_minimize_n_per_given_condition(n):
      table = ([0] * (n + 1))
      for i in range((n + 1)):
          table[i] = (n - i)
      for i in range(n, 0, (- 1)):
          if (not (i % 2)):
              table[(i // 2)] = min((table[i] + 1), table[(i // 2)])
          if (not (i % 3)):
              table[(i // 3)] = min((table[i] + 1), table[(i // 3)])
      return table[1]
source_cpp: int minimum_steps_minimize_n_per_given_condition(int n) {
    int table [ n + 1 ];
    for ( int i = 0;
    i <= n;
    i ++ ) table [ i ] = n - i;
    for ( int i = n;
    i >= 1;
    i -- ) {
      if ( ! ( i % 2 ) ) table [ i / 2 ] = min ( table [ i ] + 1, table [ i / 2 ] );
      if ( ! ( i % 3 ) ) table [ i / 3 ] = min ( table [ i ] + 1, table [ i / 3 ] );
    }
    return table [ 1 ];
  }