Challenge
Implement decreasing_prices(prices). Return the length of a longest strictly decreasing subsequence of the integer list. A subsequence preserves order but need not be contiguous. Equal values cannot extend a strictly decreasing subsequence. An empty list returns 0. For [100,80,70,120,90,110,60], return 4, using [100,80,70,60]. Aim for O(n log n).
Target complexity: O(n log 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, 70, 120, 90, 110, 60]]
Expected return
4
Arguments
[[10, 9, 2, 5, 3, 7, 101, 18, 30, 45, 60, 80, 90, 110]]
Expected return
4
Hint
Negate values and think about the smallest tail of an increasing subsequence.
The worked solution unlocks after completion, or with Premium access.