Cheapest Filler Items To Unlock A Threshold Discount
Last updated: November 29, 2026
Quick Overview
A shopper must buy a set of required items and may add items from a wishlist; a coupon takes D off any order totalling at least T. Return the minimum amount they pay and which wishlist items to add, adding filler only when it makes the order cheaper.
Pinduoduo
November 29, 20260
0
0 solved
A shopper must buy a set of required items and may add items from a wishlist; a coupon takes D off any order totalling at least T. Return the minimum amount they pay and which wishlist items to add, adding filler only when it makes the order cheaper.
Threshold discounts (man jian, such as spend 70 yuan get 20 off) are everywhere in Pinduoduo promotions, and shoppers routinely add filler items to qualify. The interviewer wants you to spot the subset-sum structure, bound the DP sensibly, and reason about when the coupon is worth using at all.
What the Interviewer Expects
- Handles the case where required items already meet the threshold
- Recognizes subset sum over wishlist prices and bounds the search to need + max price
- Compares the coupon path with simply paying the base amount
- Reconstructs which items were chosen
- Works in integer cents to avoid float error
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
- How would you handle several stacked coupons with different thresholds?
- Prices are up to 100,000 cents and the wishlist has 200 items. Is the DP still fine?
- What if each wishlist item has a value to the shopper, so filler is not pure waste?
- How would a checkout page compute this suggestion in under 50 ms?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Prices are integer cents. Let base = sum(must). If base >= T the shopper just pays base - D. Otherwise they need at least need = T - base of filler. The paid amount with the coupon is `base + ...
High-Level Design
This is a bounded subset sum: find the smallest achievable sum that is at least need. Any optimal filler set never exceeds need + max(price), because if it did you could drop one item and still be...