Equalize string

dp soln giving tle
code:https://ide.codingblocks.com/s/243539
ques:https://hack.codingblocks.com/app/contests/1289/1291/problem

you are calling rec() function in topdown function which you shouldnt do, you should only call topdown instead, moreover you are passing string each time which causes it to make a copy hence taking O(n) you should rather make strings global
Corrected Code

1 Like