Search
⌘K

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.

Comments

Your account is free and you can post anonymously if you choose.