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
4mo
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...
Delhivery Associate Software Engineer interview questions & answers
An Associate Software Engineer was asked Q. Infix to Postfix Conversion You are provided with a string EXP which represents ...read more
An Associate Software Engineer was asked Q. Maximum Sum Path in a Binary Tree Problem Statement You are provided with a bina...read more
An Associate Software Engineer was asked Q. Find First Repeated Character in a String Given a string 'STR' composed of lower...read more
Popular interview questions of Associate Software Engineer
An Associate Software Engineer was asked Q1. Infix to Postfix Conversion You are provided with a string EXP which represents ...read more
An Associate Software Engineer was asked Q2. Maximum Sum Path in a Binary Tree Problem Statement You are provided with a bina...read more
An Associate Software Engineer was asked Q3. Find First Repeated Character in a String Given a string 'STR' composed of lower...read more
>
Delhivery Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

