
Blind 75: Best Time to Buy and Sell Stock — One Pass Solution Explained
Best Time to Buy and Sell Stock — From Brute Force to One-Pass Insight Overview You’re given a list of stock prices where each index represents a day. You are allowed only one transaction: Buy on one day Sell on a future day Your goal is simple: maximize profit. If no profit is possible, return 0. Problem Constraints 1 <= prices.length <= 10^5 Expected time complexity: O(n) Only one buy and one sell Sell must happen after buy How I Approached the Problem I follow a strict rule when solving problems like this: ...