Doubt i the video

Can you tell me how time complexity is n+n-1?

if you look at recursive tree you will find that
we are calling for n-1 and n-2
but we actually calculate the value of each node only once and after calculation stored in the dp array
so for n value we have done calculation and for n-1 values we just have look the value from dp array and return

that’s why time complexity is O(n)

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.