Maximum Profit from Repeated Stock Trades

Asked at Zip · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

You are given the price of a stock on each day, in order. You start with no shares, and each day you may buy one share, sell the share you hold, or do nothing. Find the largest total profit you can make over the whole period.

Loading the problem…