Rod Cutting maximise profit

In recursive solution given by Deepak sir, why do we put int best=0; (how it is storing the previous best, and shouldnt it be “static int best=0”, else everytime it will have 0 value when function is called and not the previous best

@manasarora98
Deepak sir discussed both Top Down and Bottom Up approach for this problem. In both , he made the ‘best’ variable and it serves the same purpose in both the codes.
We are not storing the overall best answer in the best variable , we are only storing the current best i.e. the best variable only stores the max profit so far.
In Top Down method , the best variable stores the max profit that can be made with a rod of length n.
In Bottom Up method , it stores the max profit that can be made with rod of length = i .

Since we need it to store the max profit for each length seperately that is why we need to initialise to 0 everytime and cannot use a static variable.

The final answer is stored at the last index of the dp array.