Amazon VO Interview Coding Question: Build a Furniture Store Order Pricing System

19 Views
No Comments

Build a system that calculates the price of a customer’s order in a furniture store. Pricing rules are as follows:

  • Used items get a 20% discount off the original price.
  • Buying multiple items of the same category (e.g., chairs) applies an additional discount:
  • 2-3 items: 5% off
  • 4-6 items: 10% off
  • 7+ items: 15% off
  • There is a category-based pricing tier for each item similar to the following:
CATEGORY_PRICES = {'chair': {'basic': 100, 'premium': 200, 'luxury': 300},
    'table': {'basic': 250, 'premium': 500, 'luxury': 1000},
    'sofa': {'basic': 500, 'premium': 1000, 'luxury': 2000},
    'cabinet': {'basic': 300, 'premium': 600, 'luxury': 900}
}

Example usage:

items = [{'name': 'Classic Chair', 'category': 'chair', 'tier': 'basic', 'used': True},
    {'name': 'Designer Chair', 'category': 'chair', 'tier': 'premium', 'used': False},
    {'name': 'Luxury Table', 'category': 'table', 'tier': 'luxury', 'used': False}
]

Expected output:

  • Basic Chair: 100 * 0.8 = 80 (used discount)
  • Premium Chair: 200 (no used discount)
  • Both chairs get 5% category discount

This problem is about designing a pricing engine with layered discounts. You first map each item to its base price using its category and tier, then apply a 20% discount for used items. After that, items are grouped by category so a volume discount can be applied based on the number of items in the same category. A clean solution usually uses a price lookup table plus grouping or counting by category, then computes the final order total from those rules.

END
 0