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.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

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
1D dynamic programming
Delete and earn
Frequency aggregation
Coordinate compression
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported