DIY: Best Time to Buy and Sell Stock
Problem statement
You have an array for which the ith
element is the price of a given stock on day i
.
If you are only permitted to complete one transaction at most (e.g, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Note: You cannot sell a stock before you buy one. ...
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy