#K86592. Decoding Encoded Strings
Decoding Encoded Strings
Decoding Encoded Strings
You are given an encoded string where each segment is composed of a letter immediately followed by a positive integer. This integer specifies the number of times that letter should appear in the decoded string. Formally, for an encoded string \( S \), each segment is of the form \( l\,n \), where \( l \) is a letter and \( n \) is a positive integer. The decoded string is the concatenation of each letter repeated \( n \) times.
Example:
- For \( S = "a2b3" \), the decoded string is "aabbb".
- For \( S = "x1y5z2" \), the decoded string is "xyyyyyzz".
- For \( S = "a1b10c2" \), the decoded string is "abbbbbbbbbbcc".
You are required to decode multiple such encoded strings. The input begins with an integer \( T \) denoting the number of test cases, followed by \( T \) lines each containing one encoded string. For each test case, output the decoded string on a new line.
inputFormat
The first line contains an integer \( T \) (\( 1 \leq T \leq 100 \)) representing the number of test cases. The following \( T \) lines each contain a single non-empty encoded string \( S \). Each encoded string consists of segments where each segment is a letter followed by a positive integer. If the input string is empty, the output should be an empty string.
outputFormat
For each test case, print the decoded string on a separate line. The output should be printed to stdout
.
3
a2b3
x1y5z2
a1b10c2
aabbb
xyyyyyzz
abbbbbbbbbbcc
</p>