Problem: Best Time to Buy and Sell Stock
Explore how to find the maximum profit from stock prices by selecting the best day to buy and sell. This lesson teaches you to implement a single-pass solution with arrays in C#, tracking minimum price and maximum profit efficiently using iteration.
We'll cover the following...
We'll cover the following...
Statement
You are given an array prices where prices[i] represents the price of a stock on the
Your goal is to maximize your profit by selecting a single day to buy the stock and a different day in the future to sell it. The sell day must come strictly after the buy day.
Return the maximum profit achievable from ...