Get Maximum Score
Updated
Problem 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 Online Assessment questions
- 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
- Binary Tree Level Order TraversalOA · Seen Nov 2023
- Design HashMapOA · Seen Nov 2023
Similar questions at other companies
- Maximum Escape Game ScoreMicrosoft · OA
- Maximum Points by Deleting ElementsIBM · OA
- Maximum Points by Deleting ElementsWalmart · OA
- Bitwise XOR SubsequencesJP Morgan Chase · OA
- Bitwise XOR SubsequencesGoldman Sachs · OA
- Longest Common Contiguous String SequenceIntuit · OA
- Optimize Discount Selection Under a Point BudgetPalantir · OA
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Maximum Subarray Sum with Equal EndpointsGoogle · ONSITE INTERVIEW
- Word BreakMoveworks · ONSITE INTERVIEW