Tap here to switch tabs
Problem
Submissions

Problem: Maximum Linear Stock Score

Try to solve the Maximum Linear Stock Score problem.

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

Try to solve the Maximum Linear Stock Score problem.

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