Decode String Problem Statement
Your task is to decode a given encoded string back to its original form.
Explanation:
An encoded string format is <count>[encoded_string], where the 'encoded_string' inside the square brackets is to be repeated 'count' times. The 'count' is guaranteed to be a positive integer and can be greater than 9. The encoded string contains no extra whitespace and has well-formed brackets.
Input:
The input consists of multiple test cases:
The first line contains an integer 'T', representing the number of test cases.
Each test case contains a string 'S' that represents the encoded string.
Output:
For each test case, output the decoded string on a new line.
Example:
Input: 2[a]
Output: aa
Input: 3[a2[b]]
Output: abbabbabb
Constraints:
1 <= T <= 20
1 <= |S| <= 500
(where |S| is the length of the encoded string)- Time limit: 0.400 sec
Be the first one to answer
Add answer anonymously...
Top Paytm Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Paytm Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app