Quant Memo
Coding/●●●●

Longest run-up-then-run-down in prices

A "bitonic" pattern rises strictly to a single peak and then falls strictly. Given daily prices, find the length of the longest bitonic subsequence (days need not be consecutive), a stylized momentum-then-reversal move.

prices = [1, 4, 7, 2, 5, 3, 1]
-> 6        # 1, 4, 7, 5, 3, 1

Return the length of the longest bitonic subsequence in O(n^2) time.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions