101
0/304
Loading content...
A commerce pricing engine stores product catalog prices and optional category-level discount policies.
You are given two tables.
Products
Discounts
Task: For each product row, compute its discounted final price.
Rules:
Return requirements:
Supported submission environments:
Products:
| product_id | category | price |
|------------|-------------|---------|
| 1 | electronics | 1000.00 |
| 2 | apparel | 50.00 |
| 3 | electronics | 1200.00 |
| 4 | home | 500.00 |
Discounts:
| category | discount |
|-------------|----------|
| electronics | 10 |
| apparel | 20 |[
{"product_id":1,"final_price":900.0,"category":"electronics"},
{"product_id":2,"final_price":40.0,"category":"apparel"},
{"product_id":3,"final_price":1080.0,"category":"electronics"},
{"product_id":4,"final_price":500.0,"category":"home"}
]Products in missing categories keep original prices; others apply the matched discount percentage.
Products:
| product_id | category | price |
|------------|------------|-------|
| 10 | premium | 99.99 |
| 11 | clearance | 20.00 |
| 12 | regular | 45.50 |
| 13 | regular | 0.01 |
Discounts:
| category | discount |
|------------|----------|
| premium | 0 |
| clearance | 100 |[
{"product_id":10,"final_price":99.99,"category":"premium"},
{"product_id":11,"final_price":0.0,"category":"clearance"},
{"product_id":12,"final_price":45.5,"category":"regular"},
{"product_id":13,"final_price":0.01,"category":"regular"}
]0% keeps the original amount, 100% forces zero, and categories without policy default to 0%.
Products:
| product_id | category | price |
|------------|-------------|-------|
| 21 | electronics | 20.05 |
| 22 | beauty | 10.01 |
| 23 | beauty | 3.33 |
| 24 | toys | 7.77 |
Discounts:
| category | discount |
|-------------|----------|
| electronics | 50 |
| beauty | 33 |
| toys | 34 |[
{"product_id":21,"final_price":10.03,"category":"electronics"},
{"product_id":22,"final_price":6.71,"category":"beauty"},
{"product_id":23,"final_price":2.23,"category":"beauty"},
{"product_id":24,"final_price":5.13,"category":"toys"}
]Rounding follows HALF_UP at 2 decimals for deterministic discount outcomes.
Constraints