cs.thefarshad
easy Arrays & DP

Best Time to Buy and Sell Stock

Given daily `prices`, return the maximum profit from buying on one day and selling on a later day. If no profit is possible, return 0. Example: [7, 1, 5, 3, 6, 4] → 5 (buy at 1, sell at 6).

runs in your browser