Search
⌘K
Get Premium
Leetcode 2898. Maximum Linear Stock Score
Given an array of stock prices, find two indices i < j that maximize a score defined by a linear combination of prices and their indices (e.g., price[j] - price[i] plus or minus a term proportional to j−i). Solve in linear time by transforming the expression and scanning while maintaining the best prefix value (greedy / dynamic programming pattern).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.