Maximum Escape Game Score
Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Delete the 11 for 11 points, then the two 6s for 12, then the 4. That's the 27 from Example 1 of Microsoft's Maximum Escape Game Score, reported in September 2026. The statement reads like a simulation, but it's not. It's the classic pick-or-skip DP over values, dressed up as a puzzle game. If you've got an OA invite for this one, you need the reframe before you write a line of code. Greedy picking the biggest value fails, and so does actually simulating deletions. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the idea below is short enough to carry in your head.
The problem
In an escape game, players must solve puzzles to earn points and progress. One puzzle involves an array of integers and specific rules for earning points. Here are the rules: Select a value v. Remove all occurrences of that value from the array and add their sum to your score. Remove all elements equal to v + 1 or v - 1 without scoring points. Repeat steps 1 and 2 until the array is empty. Determine the maximum score that can be obtained by following these rules. Function maxEscapeGameScore(elements: int[]) → long Examples Example 1 elements = [5,6,6,4,11] return = 27 Delete 11 for 11 points. Next, delete the two 6s for 12 points, which removes 5 without scoring. Finally, delete 4 for 4 points, giving 11 + 12 + 4 = 27. Example 2 elements = [3,4,2] return = 6 Delete 4 for 4 points, which removes 3 without scoring. Deleting the remaining 2 gives a total score of 6. Constraints 1 ≤ elements.length ≤ 10^5 1 ≤ elements[i] ≤ 10^5
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: picking v kills v-1 and v+1, but every copy of v counts. So bucket the array by value into sums, where sum[v] = v * count(v). Now it's a line of buckets where you can't take two adjacent ones. That's House Robber. Run dp over values 1 to 100000: take = dp[i-2] + sum[i], skip = dp[i-1], dp[i] = max of the two. Pitfalls: use a long, since 10^5 elements of 10^5 each overflows int. Don't sort and simulate removals, that gets messy. Don't go greedy on the largest bucket, because [3,4,3] style cases break it. Gaps in values are fine, an empty bucket has sum 0 so adjacency just stops mattering. Complexity is O(n + maxValue) time and O(maxValue) space. If the live OA freezes you, StealthCoder can hand you this recurrence in real time, but you should know it cold.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Maximum Escape Game Score cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as delete and earn. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Microsoft's OA.
Microsoft reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Escape Game Score FAQ
What's the trick in Maximum Escape Game Score?+
Count each value's total contribution as value times frequency, then treat the values as a line where choosing one blocks its neighbors. That's House Robber on the buckets. The simulation wording is a distraction. Once you see the reduction, the code is about ten lines.
Why does greedy fail here?+
Taking the largest bucket can block two neighbors that together are worth more. For example, with values 2, 3, 4, picking 3 gives less than picking 2 and 4 together. You need DP to compare take versus skip at every value.
Do I need a long for the score?+
Yes. With up to 10^5 elements each up to 10^5, the total can reach 10^10, which overflows a 32-bit int. The function even returns a long. Make your bucket array and dp array long as well.
How do I handle gaps between values?+
Index buckets by value up to the max element. Missing values have sum 0, so dp just carries forward. You don't need special gap logic, the take-or-skip recurrence handles it naturally because skipping a zero bucket costs nothing.
How do I prepare for this in 48 hours?+
Solve House Robber, then Delete and Earn, which is this exact problem. Practice writing the frequency-bucket step and the two-variable rolling dp from memory. That covers the Microsoft variant reported in September 2026, and similar reductions on other problems.