Longest Palindromic subsequnce

question–>

code–>


when i was submitting the code without passing the string by referrence it is TLE , but when i passed by reference ,why was that?

Hello @sheikhhaji18 in leetcode solutions as the test cases are larger then when you dont pass the strings by reference then it forms the new string for everycall and then it performs every operations as like it has never done before.
when you pass it by reference it remember what has aleady benn done so then it becomes more optimised.
Happy Learning!!

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.