Click here to see the full article post
The crucial part of this dynamic programming question is the granular case includes n=3.
I know that in this question, all the integers are positive because money is either 0 or more, it cannot be negative. So the array input has all positive integers. If the array input has negative integers, then this solution will not work, right? Atleast for the base case , the prevMax and currMax would need to be changes to say Integer.MIN_VALUE.