Problem · Array
Get Maximum Score
Learn this problemProblem statement
Given daily stock prices in stockPrice, choose a non-empty subsequence of day indices in increasing order.
The subsequence is balanced when every consecutive chosen pair previous and current satisfies stockPrice[current] - stockPrice[previous] = current - previous. Its score is the sum of prices on the chosen days.
Return the maximum possible score of a balanced subsequence.
Function
getMaximumScore(stockPrice: int[]) → longExamples
Example 1
stockPrice = [1,5,3,7,8]return = 20Choose indices [1,3,4], giving prices [5,7,8]. Their differences equal the corresponding index differences, and the score is 5 + 7 + 8 = 20.
Constraints
1 <= stockPrice.length <= 2000001 <= stockPrice[i] <= 10^9- The answer fits a signed
long.
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023