title: Lexicographical Concatenation Substrings String
signature: function lexicographical_concatenation_substrings_string(s)
source_py: def lexicographical_concatenation_substrings_string(s):
      n = len(s)
      sub_count = ((n * (n + 1)) // 2)
      arr = ([0] * sub_count)
      index = 0
      for i in range(n):
          for j in range(1, ((n - i) + 1)):
              arr[index] = s[i:(i + j)]
              index += 1
      arr.sort()
      res = ''
      for i in range(sub_count):
          res += arr[i]
      return res
source_cpp: string lexicographical_concatenation_substrings_string(string s) {
    int n = s . length ( );
    int sub_count = n * ( n + 1 ) / 2;
    string arr [ sub_count ];
    int index = 0;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int len = 1;
    len <= n - i;
    len ++ ) arr [ index ++ ] = s . substr ( i, len );
    sort ( arr, arr + sub_count );
    string res = "";
    for ( int i = 0;
    i < sub_count;
    i ++ ) res += arr [ i ];
    return res;
  }
question_info.entry_fn_name: lexicographical_concatenation_substrings_string
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(s, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(s) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver("sqGOi", "GGOGOiOOiiqqGqGOqGOissqsqGsqGOsqGOi")
      print(string.format("TEST-0...%s",result))
  
      result = driver("ZhWXUKmeiI", "IKKmKmeKmeiKmeiIUUKUKmUKmeUKmeiUKmeiIWWXWXUWXUKWXUKmWXUKmeWXUKmeiWXUKmeiIXXUXUKXUKmXUKmeXUKmeiXUKmeiIZZhZhWZhWXZhWXUZhWXUKZhWXUKmZhWXUKmeZhWXUKmeiZhWXUKmeiIeeieiIhhWhWXhWXUhWXUKhWXUKmhWXUKmehWXUKmeihWXUKmeiIiiImmemeimeiI")
      print(string.format("TEST-1...%s",result))
  
      result = driver("tjP kR", "  k kRPP P kP kRRjjPjP jP kjP kRkkRttjtjPtjP tjP ktjP kR")
      print(string.format("TEST-2...%s",result))
  
      result = driver("qJPHNSJOUj", "HHNHNSHNSJHNSJOHNSJOUHNSJOUjJJJOJOUJOUjJPJPHJPHNJPHNSJPHNSJJPHNSJOJPHNSJOUJPHNSJOUjNNSNSJNSJONSJOUNSJOUjOOUOUjPPHPHNPHNSPHNSJPHNSJOPHNSJOUPHNSJOUjSSJSJOSJOUSJOUjUUjjqqJqJPqJPHqJPHNqJPHNSqJPHNSJqJPHNSJOqJPHNSJOUqJPHNSJOUj")
      print(string.format("TEST-3...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": "GGOGOiOOiiqqGqGOqGOissqsqGsqGOsqGOi", "inputs": {"s": "sqGOi"}}, {"idx": 1, "outputs": "IKKmKmeKmeiKmeiIUUKUKmUKmeUKmeiUKmeiIWWXWXUWXUKWXUKmWXUKmeWXUKmeiWXUKmeiIXXUXUKXUKmXUKmeXUKmeiXUKmeiIZZhZhWZhWXZhWXUZhWXUKZhWXUKmZhWXUKmeZhWXUKmeiZhWXUKmeiIeeieiIhhWhWXhWXUhWXUKhWXUKmhWXUKmehWXUKmeihWXUKmeiIiiImmemeimeiI", "inputs": {"s": "ZhWXUKmeiI"}}, {"idx": 2, "outputs": "  k kRPP P kP kRRjjPjP jP kjP kRkkRttjtjPtjP tjP ktjP kR", "inputs": {"s": "tjP kR"}}, {"idx": 3, "outputs": "HHNHNSHNSJHNSJOHNSJOUHNSJOUjJJJOJOUJOUjJPJPHJPHNJPHNSJPHNSJJPHNSJOJPHNSJOUJPHNSJOUjNNSNSJNSJONSJOUNSJOUjOOUOUjPPHPHNPHNSPHNSJPHNSJOPHNSJOUPHNSJOUjSSJSJOSJOUSJOUjUUjjqqJqJPqJPHqJPHNqJPHNSqJPHNSJqJPHNSJOqJPHNSJOUqJPHNSJOUj", "inputs": {"s": "qJPHNSJOUj"}}]