Star schema join and rollup
Your task
You have a star schema: a fact table sales as rows [product_id, amount] (amount int), and a dimension table products as rows [product_id, category] (category string). Join the fact rows to their product's category and roll up total amount per category. Fact rows whose product_id is missing from the dimension table are dropped (inner join). Return [category, total_amount] pairs sorted by category ascending. product_ids in the dimension table are unique.
Examples
star_rollup(sales: list[list], products: list[list]) -> list[list]Example 1
Input
star_rollup([[1, 100], [2, 50], [1, 25]], [[1, "books"], [2, "toys"]])Output
[["books", 125], ["toys", 50]]