Best Time to Buy and Sell Stock

Given an array prices where prices[i] is the stock price on day i, choose one day to buy and a later day to sell to maximize profit. Return the maximum profit, or 0 if no profit is possible.

**...

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: