LeetCode 121: Best Time to Buy and Sell Stock With Greedy
Subtitle / Summary The greedy idea is not “buy low, sell high” as a slogan. The precise rule is: if today is the sell day, the best buy day must be the lowest price before today. Reading time: 8-10 min Tags: Hot100, greedy, array, stock SEO keywords: LeetCode 121, Best Time to Buy and Sell Stock, greedy, historical minimum price Meta description: A pressure-first Python guide to LeetCode 121 that derives brute force, historical minimum price, and the final one-pass greedy solution. Problem Requirement You are given an array prices, where prices[i] is the stock price on day i. ...