Maximize the Minimum Game Score

You are given an array points of size n and an integer m. There is another array gameScore of size n, where gameScore[i] represents the score achieved at the i^th game. Initially, gameScore[i] == 0 for all i.

You start at index -1, which is outside the array before the first position at index 0. You can make at most m moves. In each move, you can either:

  • Increase the index by 1 and add points[i] to gameScore[i].
  • Decrease the index by 1 and add points[i] to gameScore[i].

Note that the index must always remain within the bounds of the array after the first move.

Return the maximum possible minimum value in gameScore after at most m moves.

Example 1
Inputpoints = [2,4], m = 3
Output4
The minimum value in gameScore is 4, and this is the maximum possible minimum among all configurations.
Example 2
Inputpoints = [1,2,3], m = 5
Output2
The minimum value in gameScore is 2, and this is the maximum possible minimum among all configurations.

Constraints

  • 2 <= n == points.length <= 5 * 10^4
  • 1 <= points[i] <= 10^6
  • 1 <= m <= 10^9

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate