
Asked in Paytm
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
Decode a given 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
Use recursio...read more
Help your peers!
Add answer anonymously...
Top Software Engineer Interview Questions Asked at Paytm
Q. Given an m x n matrix, where each row and each column is sorted in ascending ord...read more
Q. Given head, the head of a linked list, determine if the linked list has a cycle ...read more
Q. Explain the internal workings of a hashmap.
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Paytm Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 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

