why i am getting tle
It is giving tle
because your base condition is
if(s.length()<=1)
since you are not decreasing length of s , thus s.length is always >1 and you will never hit the base condition , so you need to call recursive function only on substring part not on whole string
refer this for clear understanding :- https://ide.codingblocks.com/s/239735
i have explained with approach and code in the above link
1 Like
Thanks ,it really helped me