Maximize Profit with Stock Transactions

Given an array prices where prices[i] is the stock price on the i-th day, you want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: