title: Lexicographical Concatenation Substrings String
signature: class Solution {
  
      public string LexicographicalConcatenationSubstringsString(string s) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(string actual, string expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(string s, string expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                string pred_result = solution_cls.PLACEHOLDER_FN_NAME(s); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  "sqGOi", 
                  "GGOGOiOOiiqqGqGOqGOissqsqGsqGOsqGOi"
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  "ZhWXUKmeiI", 
                  "IKKmKmeKmeiKmeiIUUKUKmUKmeUKmeiUKmeiIWWXWXUWXUKWXUKmWXUKmeWXUKmeiWXUKmeiIXXUXUKXUKmXUKmeXUKmeiXUKmeiIZZhZhWZhWXZhWXUZhWXUKZhWXUKmZhWXUKmeZhWXUKmeiZhWXUKmeiIeeieiIhhWhWXhWXUhWXUKhWXUKmhWXUKmehWXUKmeihWXUKmeiIiiImmemeimeiI"
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  "tjP kR", 
                  "  k kRPP P kP kRRjjPjP jP kjP kRkkRttjtjPtjP tjP ktjP kR"
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  "qJPHNSJOUj", 
                  "HHNHNSHNSJHNSJOHNSJOUHNSJOUjJJJOJOUJOUjJPJPHJPHNJPHNSJPHNSJJPHNSJOJPHNSJOUJPHNSJOUjNNSNSJNSJONSJOUNSJOUjOOUOUjPPHPHNPHNSPHNSJPHNSJOPHNSJOUPHNSJOUjSSJSJOSJOUSJOUjUUjjqqJqJPqJPHqJPHNqJPHNSqJPHNSJqJPHNSJOqJPHNSJOUqJPHNSJOUj"
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );
          }
      }
  }
  
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;
  }