Best Time to Buy and Sell Stock: the skills you need first
Updated
LeetCode · easy · arrays. Track the cheapest buy behind you. Profit is price minus that min.
Skills this problem builds on
Stuck on Best Time to Buy and Sell Stock? It is usually one of these. Get each one solid and the solution stops being a trick.
- Keep best-so-far
- Maintain running min/max
- Compare with historical state
check which ones you have 10 minutes, free, no account.
More arrays problems
- Rotate Arraymedium
- Merge Sorted Arrayeasy
- Move Zeroeseasy
- Product of Array Except Selfmedium