FastPrepShopping Cart Billing

Shopping Cart Billing

Amazon logoAmazon● EasyINTERNOA

Problem statement

An online store is holding a sale for its members. Every product has a retail price and may carry some discount tags. A member always pays the lowest price available for a product.

Each row products[i] describes one product:

  • products[i][0] is the retail price.
  • Every later entry is the name of a discount tag on that product, or "EMPTY" for an unused slot.

Each row discounts[j] = [tag, type, amount] describes one discount tag. In the rules below, price is the product's retail price. There are three tag types:

The problem statement continues
Pro

Examples

Example 1

products = [["10","d0","d1"],["15","EMPTY","EMPTY"],["20","d1","EMPTY"]]discounts = [["d0","1","27"],["d1","2","5"]]return = 35
  • Product 0 has retail price 10. Tag d0 gives 10 * 73 / 100 = 7.3, which drops to 7. Tag d1 gives 10 - 5 = 5. The lowest price is 5.
  • Product 1 has no tags, so it costs 15.
  • Product 2 has retail price 20. Tag d1 gives 20 - 5 = 15, so it costs 15.

The total is 5 + 15 + 15 = 35.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Amazon hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week