Problem · Array
Escape Game - Maximize Score
Learn this problemProblem statement
Duplicate notice: This page is a duplicate of Maximum Escape Game Score. Please ignore this page and use the canonical version.
Given an integer array elements, in each round you may choose a value v, delete all elements equal to v from the array and add them to your score, while also deleting all elements equal to v + 1 or v - 1. Those neighboring values earn no points.
Repeat until the array is empty. Return the maximum score you can obtain.
Function
maxScore(elements: int[]) → intExamples
Example 1
elements = [5, 6, 6, 4, 11]return = 27First pick 11, scoring 11 points; there are no 10s or 12s to delete, leaving [5, 6, 6, 4].
Then pick 6, scoring 12 points, while deleting the 5 and 7. The 5 is removed, leaving [4].
Finally pick 4, scoring 4 points. Total: 27.
More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026