Challenge
Implement maximum_drawdown(prices) for a list of strictly positive prices. Return the largest percentage fall from an earlier peak to a later price, rounded to two decimal places. An empty or single-price list returns 0.0. Compute 100 * (peak - price) / peak, with the peak taken only from the prices seen so far. Aim for O(n). For [100,80,120,90,110,70], return 41.67.
Target complexity: O(n)
Return values are checked by type. Use the exact function name. Print output is not your answer. Tests have time and memory limits.
Public examples
Arguments
[[100, 80, 120, 90, 110, 70]]
Expected return
41.67
Arguments
[[50, 60, 70, 80, 90, 100]]
Expected return
0.0
Hint
Track the largest price seen so far.
The worked solution unlocks after completion, or with Premium access.