Can you please explain me the need for sum[][]

why are we adding sum[i][j] please help

https://ide.codingblocks.com/s/263150 THATS my recursive code its showing 0 always

hi @chemant077, i just picked your doubt , i will provide you the answer ASAP

hi @chemant077,
let me answer your first question, we are adding sum[i][j] to include the cost occurred while joining slimes in the range i to j .

you are getting wrong answer because , you are providing wrong range to the function,
you are calling fa(0, n); but it should be fa(0, n-1); as when you are accessing sum[0][n] it accesses uninitialized value, which is 0 as sum declared as global ,

corrected code :- https://ide.codingblocks.com/s/263206

In case of any doubt feel free to ask :slight_smile:

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.