The Market Timer
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L3
Problem
A `prices` list holds one share price per trading day in chronological order. Return the largest gain from buying on one day and selling on a strictly later day, or 0 when no later day sells higher than an earlier one.
Summary
Buy low, sell later. The whole game is when.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.