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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Minimum flips required to convert given string into concatenation of equal substrings of length K
- Minimize cost to convert given string into concatenation of equal substrings of length K
- Count pair of strings whose concatenation of substrings form a palindrome
- Print all the combinations of a string in lexicographical order
- Print all lexicographical greater permutations of a given string
- Print all longest common sub-sequences in lexicographical order
- Print all distinct circular strings of length M in lexicographical order
- Generate all numbers up to N in Lexicographical Order
- Lexicographical Maximum substring of string
- K-th lexicographical string of given length
- Find the k-th string in lexicographical order consisting of n-2 X's and 2 Y's
- Largest lexicographical string with at most K consecutive elements
- Longest palindromic string formed by concatenation of prefix and suffix of a string
- Check if given string is a substring of string formed by repeated concatenation of z to a
- Check if a string is concatenation of another given string
- Sort the words in lexicographical order in Python
- Find the lexicographical next balanced bracket sequence
- Lexicographical smallest alternate Array
- Lexicographical ordering using Heap Sort
- Lexicographical smallest number after at most K consecutive swaps
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.