← Programming questions
Medium / PYTHON

Decreasing Prices

arrays · binary_search · dynamic_programming 25 minute study target

Not completed

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

Example 1

Arguments

[[100, 80, 70, 120, 90, 110, 60]]

Expected return

4
Example 2

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.

decreasing_prices.pyPython 3.12

Drafts are saved to your account, not to shared browser storage.

Sign in to submit code and save progress.

Results

Your results will appear here.

Hidden tests reveal only their pass/fail status, never their inputs or expected outputs. Runtime is observed wall time—not an inferred complexity class.

© 2026 EverythingQuant. All Rights Reserved.