Tap here to switch tabs
Problem
Submissions

Problem: Maximum Linear Stock Score

Maximum Linear Stock Score asks you to choose increasing days whose stock prices rise by exactly the number of days between each choice, then return the greatest possible sum of their prices.

Statement

You are given a 11 indexed integer array prices, where prices[i] represents the price of a given stock on day i.

A sequence of chosen indices i1<i2<⋯<iki_1 < i_2 < \dots < i_k is considered linear if for every index jj where 1<j≤k1 < j \leq k, the following condition holds:

prices[ij]−[i_j] - prices[ij−1]=ij−ij−1[i_{j - 1}] = i_j - i_{j - 1}

The score of a linear selection is the sum of prices[i][i] for all selected indices.

Return the maximum possible score of a linear selection.

Constraints:

  • 1≤1 \leq prices.length ≤105\leq 10^5

  • 1≤1 \leq prices[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Linear Stock Score

Maximum Linear Stock Score asks you to choose increasing days whose stock prices rise by exactly the number of days between each choice, then return the greatest possible sum of their prices.

Statement

You are given a 11 indexed integer array prices, where prices[i] represents the price of a given stock on day i.

A sequence of chosen indices i1<i2<⋯<iki_1 < i_2 < \dots < i_k is considered linear if for every index jj where 1<j≤k1 < j \leq k, the following condition holds:

prices[ij]−[i_j] - prices[ij−1]=ij−ij−1[i_{j - 1}] = i_j - i_{j - 1}

The score of a linear selection is the sum of prices[i][i] for all selected indices.

Return the maximum possible score of a linear selection.

Constraints:

  • 1≤1 \leq prices.length ≤105\leq 10^5

  • 1≤1 \leq prices[i] ≤109\leq 10^9