Maximize the Minimum Game Score - Problem

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.

Input & Output

Example 1 — Basic Expansion
$ Input: points = [3,1,4,2], m = 4
Output: 2
💡 Note: Start at position 0, then visit positions 1 and 2. With 4 moves, we can achieve scores [3,2,4,0], giving minimum = 2.
Example 2 — Limited Moves
$ Input: points = [1,5,2,3], m = 3
Output: 1
💡 Note: With only 3 moves, we can visit positions 0,1,2 getting scores [1,5,2,0]. Minimum among visited is 1.
Example 3 — Single Element
$ Input: points = [10], m = 2
Output: 20
💡 Note: Only one position exists. Use both moves on position 0: score[0] = 20, minimum = 20.

Constraints

  • 1 ≤ points.length ≤ 105
  • 1 ≤ points[i] ≤ 104
  • 1 ≤ m ≤ 2 × 105

Visualization

Tap to expand
Maximize the Minimum Game Score INPUT points array: 3 i=0 1 i=1 4 i=2 2 i=3 Start: index = -1 (outside) m = 4 moves max allowed moves gameScore (initial): 0 0 0 0 Goal: Maximize minimum value in gameScore n = 4 positions ALGORITHM STEPS 1 Binary Search Setup Search range: [0, max*m/n] Try mid as target min 2 Greedy Expansion For each position, calc visits: ceil(target/pts[i]) 3 Count Total Moves Sum moves needed for each position to hit target 4 Check Feasibility If moves <= m: try higher Else: try lower target Move Simulation (m=4) Move 1: -1 --> 0, score[0]+=3 Move 2: 0 --> 1, score[1]+=1 Move 3: 1 --> 2, score[2]+=4 Move 4: 2 --> 3, score[3]+=2 gameScore = [3,1,4,2] FINAL RESULT Final gameScore: 3 1 4 2 minimum OUTPUT 2 Why 2? With 4 moves, we must visit each position at least once. min(3,1,4,2) = 1, but greedy optimization achieves min = 2 Key Insight: Use binary search on the answer! For a target minimum value, greedily compute minimum moves needed. Each position i needs ceil(target/points[i]) visits. Moves include forward steps + back-and-forth for revisits. If total moves <= m, target is achievable. Binary search finds the maximum achievable minimum score. TutorialsPoint - Maximize the Minimum Game Score | Greedy Expansion Approach
Asked in
Google 35 Meta 28 Amazon 25 Microsoft 20
28.5K Views
Medium Frequency
~35 min Avg. Time
890 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen