I am new to DP and recursion.Can anyone help me explaining how to solve this qstn by recursion(so that i can approach with DP).plz explain and give the pseudo code as i am new to this topic
Here is my solution:
using namespace std;
long long ans=0, max=0;
Start from the rear. If current value is smaller than current maximum, then sell at that point(add diff to answer). Otherwise make this the current maximum.