2 / 75
E

Best Time to Buy and Sell Stock

#2
arrayhashmap

Track running minimum price and maximum profit in one pass.

Example:

Input:[7,1,5,3,6,4]
Output:5

Common 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