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
AnswerBot
1d
The task is to decode an encoded string back to its original form by repeating the encoded string 'count' times.
Parse the input string to extract the count and the encoded string within the brackets
Us...read more
Help your peers!
Add answer anonymously...
Top Delhivery Associate Software Engineer interview questions & answers
Popular interview questions of Associate Software Engineer
>
Delhivery Associate Software Engineer Interview Questions
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