Company: Amazon university talent Sde-1_10may
Difficulty: medium
Category Browse Engine When a customer opens a category page such as Electronics , they expect to see everything filed under it — phones, cameras, smart-home gear — not only the listings tagged at the top level. Categories form a parent–child hierarchy, so browsing a category must reach every level beneath it. Results must also be region-specific: a customer browsing US must never see a listing from another region. Finally the results must come back ranked by popularity. Your job is to implement that browse engine. Category hierarchy Each category has an id and a parent. A category whose parent is * is top-level . Different top-level categories are completely separate: browsing ELEC must never return anything filed under HOME . The categories always form a forest — every parent that is not * is the id of some category in the input, and no category is its own ancestor. What a browse request must return For each request, holding a category id, a region and a result limit, apply these thr