Best Time to Buy and Sell Stock (One Transaction)

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

Return the maximum profit possible. Return ...

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: