Given a string, find concatenation of all substrings in lexicographic order.
Input : s = “abc”
Output : aababcbbcc
The substrings of s in lexicographic order are “a”, “b”, “c”, “ab”, “abc”, “bc”. Concatenation of substrings is “a”+”ab”+”abc”+”b”+”bc”+”c” = “aababcbbcc”.
Input : s = “cba”
Output : abbaccbcba
1. Find all the substrings of string and store it in a string array. The size of array would be n*(n+1)/2 where n is length of input string.
2. Sort the string array to make them all in lexicographical order.
3. Concatenate the strings of string array in another empty string.
- Lexicographical Maximum substring of string
- Print all the combinations of a string in lexicographical order
- Print Concatenation of Zig-Zag String in 'n' Rows
- Ropes Data Structure (Fast String Concatenation)
- Number of substrings of a string
- Replace two substrings (of a string) with each other
- Split the string into substrings using delimiter
- Number of even substrings in a string of digits
- Count of substrings of a binary string containing K ones
- Sum of all substrings of a string representing a number | Set 1
- Different substrings in a string that start and end with given strings
- Number of substrings of one string present in other
- Program to print all substrings of a given string
- Counting even decimal value substrings in a binary string
- Minimum changes to a string to make all substrings distinct
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.