Decode String (LC #394) expands patterns like [a[c]] to accaccacc. Use two stacks: one for repeat counts, one for strings. When you see a digit, parse the full number. When you see '[', push current string and count, reset both. When you see ']', pop count and previous string, append current string repeated count times to previous. When you see a letter, append to current string. This runs in time where maxK is the max repeat. The pattern handles any nested structure.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/stacks-queues/decode-string
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████