Pattern Recognition Drill
Easy Greedy
The Problem
Find maximum profit from one buy and one sell (buy before sell).
What approach would you use?
Think about it before scrolling down.
Track min_price. At each day: max_profit = max(max_profit, price - min_price). O(n).
DP formulation works but is overkill. Greedy with running min is simpler.
Common Trap
Brute force checking all (buy, sell) pairs is O(n²). The running minimum insight makes it O(n).