Code producing Runtime error on Equalize String problem

I’ve written bot bottom up and top down approach but they are giving run error on few test cases. But it runnig fine on my IDE.

hello @rishabhtyagi.2306

please share ur code using cb ide

Here is the link to my code

@rishabhtyagi.2306
declare ur dp array as global array and then it will work.

Thanks a lot It worked.
But can you please explain why we need to declare the dp array globally and why It didn’t worked locally ???

in global scope we can decalre large memory compared to function scope ,thats why

Okay Thanks for the help. @aman212yadav

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.