You are given a string that contains encoded segments in the form of k[...], where the substring inside the brackets must be repeated k times. The value k will always be a positive integer.
The brackets are always properly matched, and the input will not contain invalid patterns.
Your task is to process the encoding and return the fully decoded string.
Input: s = "4[x]"
Output: "xxxx"
Input: s = "2[ab3[c]]"
Output: "abcccabccc"
Input: s = "3[z]y2[pq]"
Output: "zzzypqpq"
Accepted:
Submission: