Maximum Points by Deleting Elements
Reported by candidates from IBM's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Brute force dies here. With up to 10^5 elements and values up to 10^5, trying every order of picks is hopeless, and that's the whole point of this IBM OA question reported in September 2026. Maximum Points by Deleting Elements looks like a game, but it's a dressed-up House Robber on value counts. If your OA invite lands in the next day or two, learn the reduction and you're mostly done. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the idea below is short enough to hold in your head.
The problem
You are given an integer array elements. Repeat these operations until the array is empty: Select a remaining value v. Remove every occurrence of v and add their sum to your score. Remove every occurrence of v - 1 and v + 1 without scoring those values. Return the maximum score that can be earned. Function maxPoints(elements: int[]) → long Examples Example 1 elements = [5,6,6,4,11] return = 27 Take 11 for 11 points, both copies of 6 for 12 points, and 4 for 4 points, totaling 27. Example 2 elements = [3,4,2] return = 6 Choose 2 and 4. They do not conflict and contribute 2 + 4 = 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, so the choice depends only on values, not positions. Build an array points[v] = v * count(v) for every v up to the max. Now you can't take two adjacent indices. That's House Robber: dp[i] = max(dp[i-1], dp[i-2] + points[i]). Check example 1: 4 + 12 + 11 = 27, since 4, 6 and 11 are non-adjacent. The common pitfall is overflow. Sums can reach 10^5 * 10^5 = 10^10, so use a 64-bit type, which is why the return is long. Another trap is sorting and simulating deletions greedily, which fails. Use counting plus rolling variables for O(n + maxValue) time. If you freeze during the live OA, StealthCoder can surface this reduction and the code, but you should recognize the pattern first.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Maximum Points by Deleting Elements 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
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 IBM's OA.
IBM reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Points by Deleting Elements FAQ
What's the trick in Maximum Points by Deleting Elements?+
Collapse the array into total points per value: v times its count. Taking v forbids v-1 and v+1, so you can't pick adjacent values. That turns it into the House Robber recurrence over value indices, solved in linear time.
How hard is this IBM OA question really?+
Medium. The code is about ten lines once you see the reduction. The difficulty is spotting that positions don't matter and that adjacency is by value. If you've seen House Robber, it clicks fast.
Why does brute force fail here?+
With n up to 10^5, trying every selection order is exponential. Even recursion over distinct values with memo only works once you notice the state depends on the value index alone. Counting plus DP gives O(n + max value).
What data type do I need for the answer?+
A 64-bit integer. A value of 10^5 appearing 10^5 times gives a sum around 10^10, which overflows 32-bit ints. The function signature returns long for exactly this reason.
How do I prepare for this in 48 hours?+
Solve House Robber, then Delete and Earn, which is this same setup. Practice building the points array and the rolling two-variable DP until you can write it from memory. Then test an input with all equal values and one with gaps between values.