Pattern Recognition Drill
Easy Sliding Window
The Problem
Given an array of stock prices by day, find the maximum profit from one buy-sell pair.
What approach would you use?
Think about it before scrolling down.
Track running min price; at each step profit = price - min_so_far. O(n).
Left at buy, right at sell. Move left when right finds lower price.
Common Trap
Don't try all O(n²) pairs. The running minimum makes it one-pass.