Back to problems

Optimal Stock Price Subsequence

Algorithm · Point72 · Hard

This problem is a variant of the classic Maximum Balanced Subsequence Sum challenge. If you haven't solved that one yet, it's advisable to do so first. You are given an integer array stockPrice of length n, where stockPrice[i] is the closing price of a stock on day i. A subsequence is any ordered selection of elements that preserves the original index order. A subsequence of stockPrice is called balanced if for every pair of consecutive chosen indices i 5 1 ≤ stockPrice[i] ≤…

Checking your access…