101
0/304
Loading content...
A retail intelligence team receives product pricing in long format, where each row represents one product-store quote. They need a dynamic pivot view that is stable for downstream systems even when the set of stores changes over time.
Table: Products
Data guarantees:
Task: Build a canonical dynamic pivot string per product.
Definitions:
Output requirements:
Supported submission environments:
Products:
| product_id | store | price |
|------------|----------|-------|
| 1 | Shop | 110 |
| 1 | LC_Store | 100 |
| 2 | Nozama | 200 |
| 2 | Souq | 190 |
| 3 | Shop | 1000 |
| 3 | Souq | 1900 |[
{"product_id":1,"store_price_map":"LC_Store=100;Nozama=NULL;Shop=110;Souq=NULL"},
{"product_id":2,"store_price_map":"LC_Store=NULL;Nozama=200;Shop=NULL;Souq=190"},
{"product_id":3,"store_price_map":"LC_Store=NULL;Nozama=NULL;Shop=1000;Souq=1900"}
]Global store domain is {LC_Store, Nozama, Shop, Souq}. Every product must list all four stores in lexicographic order, filling missing prices with NULL.
Products:
| product_id | store | price |
|------------|-------|-------|
| 10 | A1 | 7 |
| 10 | A10 | 5 |
| 11 | A2 | 9 |[
{"product_id":10,"store_price_map":"A1=7;A10=5;A2=NULL"},
{"product_id":11,"store_price_map":"A1=NULL;A10=NULL;A2=9"}
]Lexicographic ordering is string-based, so A10 appears between A1 and A2.
Products:
[][]No rows means no products and no store domain, so output is empty.
Constraints