Because the problems later are relied on the problems before, such as we use MIN(i) to represent the lowest

price before the ith day, and MAX(i) to represent the max profit before the ith day, so, for a string of length 6, when we consider the max profit of the whole process MAX(5), we found that it relied on all the days before it, so MIN(5) = min(prices[5], MIN(5)), MAX(5) = max(prices[5] - MIN(5), MAX(4)).