title: Form Minimum Number From Given Sequence 1
signature: class Solution {
  
      public String formMinimumNumberFromGivenSequence1(String seq) {
source_py: def form_minimum_number_from_given_sequence_1(seq):
      n = len(seq)
      if (n >= 9):
          return '-1'
      result = ([None] * (n + 1))
      count = 1
      for i in range((n + 1)):
          if ((i == n) or (seq[i] == 'I')):
              for j in range((i - 1), (- 2), (- 1)):
                  result[(j + 1)] = int(('0' + str(count)))
                  count += 1
                  if ((j >= 0) and (seq[j] == 'I')):
                      break
      return result
source_cpp: string form_minimum_number_from_given_sequence_1(string seq) {
    int n = seq . length ( );
    if ( n >= 9 ) return "-1";
    string result ( n + 1, ' ' );
    int count = 1;
    for ( int i = 0;
    i <= n;
    i ++ ) {
      if ( i == n || seq [ i ] == 'I' ) {
        for ( int j = i - 1;
        j >= - 1;
        j -- ) {
          result [ j + 1 ] = '0' + count ++;
          if ( j >= 0 && seq [ j ] == 'I' ) break;
        }
      }
    }
    return result;
  }
question_info.extension: java
question_info.entry_fn_name: formMinimumNumberFromGivenSequence1
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": "[2, 1]", "inputs": {"seq": "D"}}, {"idx": 1, "outputs": "[1, 2]", "inputs": {"seq": "I"}}, {"idx": 2, "outputs": "[3, 2, 1]", "inputs": {"seq": "DD"}}, {"idx": 3, "outputs": "[1, 2, 3]", "inputs": {"seq": "II"}}, {"idx": 4, "outputs": "[2, 1, 4, 3, 5]", "inputs": {"seq": "DIDI"}}, {"idx": 5, "outputs": "[1, 2, 6, 5, 4, 3]", "inputs": {"seq": "IIDDD"}}, {"idx": 6, "outputs": "[3, 2, 1, 6, 5, 4, 7, 9, 8]", "inputs": {"seq": "DDIDDIID"}}, {"idx": 7, "outputs": "[7, 6, 5, 4, 3, 2, 1]", "inputs": {"seq": "176297"}}, {"idx": 8, "outputs": "[2, 1]", "inputs": {"seq": "1"}}, {"idx": 9, "outputs": "[7, 6, 5, 4, 3, 2, 1]", "inputs": {"seq": "XHkhZq"}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String seq, String expected){
          try{
              Driver driver = new Driver();
              if (driver.run(seq,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("D", "[2, 1]");
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("I", "[1, 2]");
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("DD", "[3, 2, 1]");
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("II", "[1, 2, 3]");
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("DIDI", "[2, 1, 4, 3, 5]");
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("IIDDD", "[1, 2, 6, 5, 4, 3]");
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("DDIDDIID", "[3, 2, 1, 6, 5, 4, 7, 9, 8]");
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("176297", "[7, 6, 5, 4, 3, 2, 1]");
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("1", "[2, 1]");
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("XHkhZq", "[7, 6, 5, 4, 3, 2, 1]");
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String seq, String expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(seq),expected);
      }
      
      public boolean validateSolution(String actual, String expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__