Deepest Fall From a High
On each day, the fall is how far the price sits below the highest price so far, as a share of that high: (high - price) / high. Return the largest fall over all days.
Example 1
prices [100,120,90,110,60,130]
returns 0.5
The high is 120 when the price falls to 60: (120 - 60) / 120 is 0.5.
Constraints
1 <= len(prices) <= 1001 <= prices[i] <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Distance From a CellMedium
- Halfway PointMedium
- Highest Cell PositionMedium
- Matching PairsMedium
- Mean of Each GroupMedium
- Multiplication TableMedium
- Order by ScoreMedium
- Pairs Hitting TargetMedium