Codeforces F-String Game

I getting TLE in test case 14.

Problem Link-https://codeforces.com/edu/course/2/lesson/6/2/practice/contest/283932/problem/F

My solution-

If you observe the good method you’d find that it runs in O(|t|^2).
Our worst-case input sample would be:

[a]*199999 b
b
1 2 3 4 ... 2000000
1 Like