Input Format: The
first line contains S. Output Format: The first line contains the expanded
string value.
Boundary Conditions: Length of S is from 2 to 100.
Example
Input/Output 1:
Input:
4a5h
Output:
aaaahhhhh
Explanation: As it is 4a and 5h, four a's are printed followed by 5 h's
Example Input/Output 2:
Input:
1k2b4k
Output:
kbbkkkk
Source Code://Python
import re
n=re.split('(\d+)',input().strip()) //(\d+)=split numbers and
char in string
for i in range(1,len(n)):
if i%2==0:
print(n[i]*int(n[i-1]),end="")
In java??
ReplyDeletein c please
ReplyDelete