← Amazon Interview Insights

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

Intermediate
Jun 2026

Summary

Amazon SWE online assessment with a shipping cost calculation problem. Pretty straightforward tiered pricing logic but the input parsing tripped me up more than I expected.

Questions Asked (1)

Q1

Given a list of item weights and a tiered pricing table with weight ranges and rates, calculate the total shipping cost for an order, rounded to two decimal places.

Algorithms & Data Structures
Author's notes

The logic itself isn't hard once you see it, each item's weight maps to exactly one rate bracket and you multiply and sum.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the input format and pricing table structure, then design an algorithm that iterates through each item, determines its weight tier, and accumulates the cost. Discuss handling edge cases like weights exactly on tier boundaries and rounding, and analyze time complexity.

Pro tip: Mention that you would sort the pricing table by weight ranges and use binary search for O(log n) tier lookup per item, demonstrating optimization for large orders. Also, explicitly state that you would use integer arithmetic for currency to avoid floating-point errors, then round only at the end.

1. Clarify requirements and assumptions

Ask about input format (e.g., list of weights, pricing table as list of (min, max, rate)), whether ranges are inclusive/exclusive, and rounding rules. Confirm that each item is priced independently based on its weight.

2. Design the algorithm

Outline a function that takes the weights and pricing table, and for each weight, finds the applicable rate and adds weight * rate to the total. Discuss naive linear search vs. optimized binary search after sorting the table.

3. Handle edge cases and precision

Address weights exactly on boundaries, weights outside the table (e.g., error or default), and rounding to two decimal places. Recommend using integer cents or Decimal to avoid floating-point issues.

4. Analyze complexity and test

State time complexity (O(n log m) with binary search, where n is number of items and m is number of tiers) and space complexity. Walk through a small example to verify correctness.

Key Points to Mention

  • Clarify input format and pricing table structure (e.g., list of tuples, inclusive/exclusive bounds).
  • Use binary search on sorted weight ranges for efficient tier lookup.
  • Handle boundary conditions (weight exactly at tier limit) and out-of-range weights.
  • Avoid floating-point errors by using integer arithmetic (cents) or Decimal, rounding only at the end.
  • Analyze time and space complexity, and discuss potential optimizations for large inputs.
  • Test with edge cases like empty list, single item, and weights at boundaries.

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