Best Time to Buy and Sell Stock

Given an array prices, where prices[i] is the price of a stock on day i, you may complete at most one transaction: buy on one day and sell on a later day.

Return the maximum profit. Return 0 ...

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: