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:
- Number of substrings of a string
- Number of even substrings in a string of digits
- Number of substrings of one string present in other
- Sum of all substrings of a string representing a number | Set 1
- Number of substrings divisible by 6 in a string of integers
- Number of substrings with odd decimal value in a binary string
- Minimum number of given operations required to convert a string to another string
- Given a binary string, count number of substrings that start and end with 1.
- Split the binary string into substrings with equal number of 0s and 1s
- Rearrange the string to maximize the number of palindromic substrings
- Count the number of vowels occurring in all the substrings of given string
- Count number of substrings of a string consisting of same characters
- Count of substrings which contains a given character K times
- Sum of all substrings of a string representing a number | Set 2 (Constant Extra Space)
- Minimum number of substrings the given string can be splitted into that satisfy the given conditions
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.
Improved By : sanjeev2552