Decode strings like 3[a2[c]] → accaccacc: k[...] repeats the bracketed part k times (k can have several digits), and brackets nest. Implement decode(s) with a stack, in time proportional to the output length.
3[a2[c]]
accaccacc
k[...]
k
decode(s)