2 / 75
Track running minimum price and maximum profit in one pass.
Example:
Input:
[7,1,5,3,6,4]Output:
5Common Mistakes:
- Off-by-one indexing
- Not handling edge cases (null/empty)
Notes:
Edge cases: duplicates, empty inputs, negative numbers where applicable.
💻
Java Solution Hidden
Enable “Show Full Solution” to view the code
Track running minimum price and maximum profit in one pass.
Example:
Input:
[7,1,5,3,6,4]Output:
5Common Mistakes:
- Off-by-one indexing
- Not handling edge cases (null/empty)
Notes:
Edge cases: duplicates, empty inputs, negative numbers where applicable.
2/75
Best Time to Buy and Sell Stock