**************knapsack 1

i am not understanding the return statement in the solve function

Hey in return statement we are using max_element function which finds and return maximum value form an array/container
Here we are returning max value in last row of matrix whose starting location is dp[n] and ending location is dp[n]+W+1

Can you please explain by taking one example and making a matrix of it

What exactly you are not able to understand, how to apply DP on this or knapsack problem overall?

I just want one example explained in the form of matrix and finally what value is returned from that matrix

Here, check this : https://www.youtube.com/watch?v=8LusJS5-AGo