List Every Gift Card Denomination Mix That Hits an Exact Total

Last updated: November 29, 2026

Quick Overview

Given distinct gift card denominations and a target amount, return every combination (with unlimited reuse of a denomination) that sums exactly to the target, each combination listed once regardless of order.

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

0

0

0 solved


Given distinct gift card denominations and a target amount, return every combination (with unlimited reuse of a denomination) that sums exactly to the target, each combination listed once regardless of order.

A technical-screen backtracking question in Amazon's style, framed around a gift card purchase flow that suggests ways to reach a requested amount. It tests reuse semantics, ordering to avoid permutations of the same combination, and pruning by sorted values.

What the Interviewer Expects
  • Allows reuse by recursing at the same index
  • Avoids duplicate permutations by never going back to earlier indexes
  • Sorts and breaks once a denomination exceeds the remainder
  • Copies the path at a hit
  • Discusses exponential output and a DP for counting
Key Topics to Cover
backtracking
combinations
pruning
dynamic programming
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
  • How would you count combinations without listing them?
  • How would you return the combination using the fewest cards?
  • What changes if each denomination can be used at most once and may repeat in the input?
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

Denominations are distinct positive integers; the target is a positive integer. Each combination is a multiset; [10, 50] and [50, 10] are the same and must appear once....

High-Level Design

Enumerate combinations in non-decreasing order of denomination. Recursing with the same index i allows reuse, and never revisiting indexes below i prevents permutations of the same mix. Sorting en...


Submit Your Answer
Markdown supported