← Amazon Interview Insights

Amazon·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Apr 2026

Summary

Amazon SWE online assessment with a DP/state compression problem involving bundle pricing. The problem was a variant of the shopping offers type where you have to figure out the minimum cost given unit prices, special bundle deals, and required quantities.

Questions Asked (1)

Q1

Given a list of item prices, a set of bundle offers (each specifying quantities of items and a bundle price), and a required quantity for each item, find the minimum total cost to fulfill the requirements. You can use each bundle any number of times and also buy items individually.

Algorithms & Data Structures
Author's notes

This is basically a state compression DP where each state is the current quantity vector of items you still need.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as an integer linear program or a shortest path problem where states represent remaining quantities. Use dynamic programming with memoization to compute the minimum cost for each state, considering all possible bundle and individual purchases. Optimize by pruning dominated states and using bounds to limit the search space.

Pro tip: Start by discussing the naive DP and its complexity, then propose optimizations like state compression or A* search to show depth. Mention that in practice, you'd validate with small cases and consider using an ILP solver if constraints are large.

1. Understand the problem and constraints

Clarify input sizes, whether quantities are small, and if bundles can overshoot requirements. Discuss if items are distinct or interchangeable.

2. Formulate as an optimization problem

Define state as the vector of remaining quantities. The cost to reach zero state is the minimum over all actions (buy individual item or apply bundle) of action cost + cost of resulting state.

3. Design a dynamic programming solution

Use memoization with a map from state to min cost. For each state, iterate over all possible actions, compute new state, and recurse. Base case: all zeros -> cost 0.

4. Optimize and handle large inputs

Prune states where any quantity is negative (overshoot) if not allowed, or allow overshoot but cap at zero. Use bounds (e.g., greedy solution) to prune branches. Consider A* with admissible heuristic.

5. Analyze complexity and test

Time complexity is O(product of (required_i+1) * number of actions). Discuss trade-offs and test with edge cases like no bundles, bundles more expensive than individual, etc.

Key Points to Mention

  • State representation and transition
  • Dynamic programming with memoization
  • Handling overshoot and negative quantities
  • Complexity analysis and pruning techniques
  • Alternative approaches: integer linear programming, shortest path
  • Edge cases: empty requirements, bundles with zero cost, etc.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.