Maximize Promotion Value Without Running Deals on Adjacent Days
Last updated: November 29, 2026
Quick Overview
A seller has a list of projected values for running a promotion on each day, but promotions cannot run on two consecutive days. Return the maximum total value achievable.
Amazon
November 29, 20260
0
0 solved
A seller has a list of projected values for running a promotion on each day, but promotions cannot run on two consecutive days. Return the maximum total value achievable.
A first DP question in the Amazon online assessment style, framed around seller promotions where back-to-back deals cannibalize each other. The interviewer checks that you define a clean state, write the recurrence, and reduce memory to O(1).
What the Interviewer Expects
- Define the state as best total up to day i
- Recurrence: best(i) = max(best(i-1), best(i-2) + value[i])
- Roll the array into two variables
- Handle empty and single-day inputs
- O(n) time, O(1) space
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 days form a cycle (the last day is adjacent to the first)?
- What if promotions must be at least k days apart?
- How would you return which days were chosen?
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 of non-negative integers values, one per day. Output: maximum sum of a subset with no two adjacent days. Empty list returns 0....
High-Level Design
Greedy (take the largest remaining day, block its neighbors, repeat) fails: on [5, 6, 5] it takes 6 and blocks both 5s, scoring 6, while the answer is 10. Alternating even and odd days also fails, f...