# breaking it down advanced

Best Market Day Pair

The fruit market posts next week's apple prices. You'll buy ONE crate one day and sell it a LATER day — plan the best profit! 🍎

You get the daily prices. Print the biggest possible profit, or 0 if prices only ever fall. One pass is enough — think about what you'd track.

Example:

Input: prices = [7, 1, 5, 3, 6, 4] Output: 5

Buying at the cheapest price seen so far (1, on day 2) and selling at the best later price (6, on day 5) gives a profit of 6 - 1 = 5.

💡 need a hint?

brk-best-market-day.py🔒 given lines are locked — write your code in between
loading...