The recommender needs each order collapsed into the set of products it contained.
One row per order_id, with the columns:
order_idskus — the distinct non-null skus, sorted ascendingsku_count — how many are in skustotal_qty — the sum of qty over every line, resolved or not| order_id | sku | qty |
|---|---|---|
| 5 | TEA | 1 |
| 5 | TEA | 2 |
| 5 | JAM | 1 |
| order_id | skus | sku_count | total_qty |
|---|---|---|---|
| 5 | [JAM, TEA] | 2 | 4 |
skus, a sku_count of 0, and its quantities summed.skus must be sorted. A set has no order, and an array in a different order is a different value however right its contents are.order_items| qty | sku | order_id |
|---|---|---|
| 2 | APPLE | 1 |
| 1 | BREAD | 1 |
| 3 | MILK | 2 |
| order_id | skus | sku_count | total_qty |
|---|---|---|---|
| 1 | ["APPLE","BREAD"] | 2 | 3 |
| 2 | ["MILK"] | 1 | 3 |
order_items| qty | sku | order_id |
|---|---|---|
| 1 | TEA | 5 |
| 2 | TEA | 5 |
| 1 | JAM | 5 |
| order_id | skus | sku_count | total_qty |
|---|---|---|---|
| 5 | ["JAM","TEA"] | 2 | 4 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.