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)
- Longest palindromic String formed using concatenation of given strings in any order
- Number of substrings of a string
- Replace two substrings (of a string) with each other
- Number of substrings of one string present in other
- Number of even substrings in a string of digits
- Program to print all substrings of a given string
- Split the string into substrings using delimiter
- Different substrings in a string that start and end with given strings
- Sum of all substrings of a string representing a number | Set 1
- Count of substrings of a binary string containing K ones
- 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 email@example.com. 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.