Stringoholics time limit exceded error

question - https://www.interviewbit.com/problems/stringoholics/
my solution- https://ide.geeksforgeeks.org/jU5zVWM7C2
I am unable to thing the optimal solution if available than this.

@sanjeetboora sir, can you find out where i can improve my solution.


checkout this blog
time complexity of substr in c++ is O(n)
which makes your solution’s time complexity O(n^2).
That’s why you are getting TLE.