Company: Zomato
Difficulty: medium
Decode String Problem Description Given an encoded string A consisting of lowercase English alphabets, square parentheses, and digits. The encoding rule is X[encoded_string] , where the encoded_string inside the square brackets is being repeated exactly X times. Note that X is guaranteed to be a positive integer. Find and return the decoded string. Note: You may assume that the original data does not contain any digits and that digits are only for those repeat numbers, X. For example, there won't be input like 3a or 2[4]. You may assume that the input string is always valid. No extra white spaces, square brackets are well-formed, etc. You may assume that the length of the decoded string will not exceed 200000. Input Format The only argument given is string A. Output Format Return the decoded string. Constraints 1 <= length of the string <= 100000 Examples Example 1: Input: A = "a[a]2[b]c" Output: "aaabcbc" Example 2: Input: A = "a[a[c]2]" Output: "aaccac" Example 3: Input: A = "2