Best Time to Buy and Sell Stock
Given an array prices where prices[i] is the stock price on day i Find the maximum profit from buying and selling once You must buy before you sell Return 0 if no profit is possible Example: [7,1,5,3,6,4] => 5 (buy at 1, sell at 6)
Best Time to Buy and Sell Stock is the sliding window pattern: grow, shrink, and maintain just enough state to stay linear. It's a great warm-up that builds stateful scanning without a ton of moving parts. The trap is updating window state in the wrong order when you expand or shrink.

Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.