Wrong output coming


for input- 4
1 2 3 4
output should be 6, but it is coming 4 Please help

Hello @Akshay123,

I have mode few corrections:

Let me know if you don’t understand something.

top down approach is more easy to understand than this one

Hello @Akshay123,

Yes, bottom up approach is lil tricky to find but it is more memory efficient as it does not occupies call stack which sometimes lead to stack overflow.

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.