Given a string str, the task is to repeat every substring of the string X number of times where X is the number composed of the consecutive digits present just after the substring in the original string. For example, if str = “g1e2ks1” then the resultant string will be “geeks”.
Input: str = “2a10bd3”
First digit “2” is unnecessary as there is no valid substring before it.
“a” will be repeated 10 times and then “bd” will be repeated thrice.
Input: str = “g1ee1ks1for1g1e2ks1”
Approach: Find the first valid substring i.e. the substring which doesn’t contain any digit then parse the integer present just after the found substring using parseInt() and then repeat the found substring the required number of times. Repeat these steps for all valid substrings and then print the resultant string.
Below is the implementation of the above approach:
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
- Minimum shifts of substrings of 1s required to group all 1s together in a given Binary string
- Count of substrings which contains a given character K times
- Count distinct substrings that contain some characters at most k times
- Count substrings with each character occurring at most k times
- Minimum number of substrings the given string can be splitted into that satisfy the given conditions
- Generate a string whose all K-size substrings can be concatenated to form the given string
- Count of substrings of a string containing another given string as a substring
- Minimum flips required to generate continuous substrings of 0’s and 1’s
- Reverse the substrings of the given String according to the given Array of indices
- Count the number of vowels occurring in all the substrings of given string
- Given a binary string, count number of substrings that start and end with 1.
- Minimum number of given operations required to convert a string to another string
- C++ program to concatenate a string given number of times
- Number of times the given string occurs in the array in the range [l, r]
- Lexicographically smallest permutation of a string that contains all substrings of another string
- Different substrings in a string that start and end with given strings
- Permutation of given string that maximizes count of Palindromic substrings
- Python program to print the substrings that are prefix of the given string
- Queries to find the count of vowels in the substrings of the given 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.