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)
- Replace two substrings (of a string) with each other
- Number of substrings of a string
- Number of even substrings in a string of digits
- Different substrings in a string that start and end with given strings
- Count of substrings of a binary string containing K ones
- Split the string into substrings using delimiter
- Program to print all substrings of a given string
- Sum of all substrings of a string representing a number | Set 1
- Number of substrings of one string present in other
- Number of substrings with odd decimal value in a binary string
- Counting even decimal value substrings in a binary string
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.