Skip to content

Stock Buy and Sell ​

Stock Buy and Sell — LeetCode

Given daily prices of a stock, find the maximum profit from a single buy followed by a later sell.

Approach ​

Go from 0 to N, find the lowest price on the way, and find the price[i] - currentLowest. If it is higher than maxProfit, update

Remarks ​