Problem 2291 · Medium

Maximum Profit From Trading Stocks

A 0/1 knapsack over the budget: each stock is bought or skipped, and the table keeps the best profit per budget.

Open the interactive visualisation