Maximize Points When Claiming a Value Voids Its Neighbors
Last updated: November 29, 2026
Quick Overview
In a Play Games promo, you are given a list of reward values; claiming a reward of value v earns v points but voids every reward of value v - 1 and v + 1. Return the maximum points you can collect.
0
0
0 solved
In a Play Games promo, you are given a list of reward values; claiming a reward of value v earns v points but voids every reward of value v - 1 and v + 1. Return the maximum points you can collect.
Google interviewers like problems where the DP is not on the input order but on a transformed axis. The check here is whether you see that duplicates should be claimed together and that the problem becomes take-or-skip over sorted values.
What the Interviewer Expects
- Notice that claiming one copy of v means you should claim all copies
- Aggregate totals per distinct value
- Reduce to non-adjacent selection over consecutive values
- Handle gaps between values without wasting time
- Explain complexity with respect to distinct values
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if claiming v voids values within distance d, not just 1?
- Values are up to 10^9 but there are only 10^5 rewards. Does your solution still work?
- Return the set of values claimed.
- Claiming v voids only one copy of v - 1 and v + 1. How does this change?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list vals of positive integers. Repeatedly claim any remaining reward; claiming value v adds v and deletes all remaining rewards equal to v - 1 or v + 1. Output the maximum total. Once you cl...
High-Level Design
Compute gain[v] = v * count(v). Now choosing a value v forbids v - 1 and v + 1, which is take-or-skip over the sorted distinct values. Walk distinct values in increasing order. If the current value ...