Best Time to Buy and Sell Stock — one-pass scan
Walk the prices once. Remember the cheapest day so far; check the profit of selling today against it.
Try:
← Prev
Next →
▶ Play
Reset
cheapest so far =
–
best profit =
0
today
cheapest so far (buy)
best sell day