← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design a co-purchase recommendation system for Snap’s e-commerce platform. You are given a list of orders, each represented as a list of product IDs that were bought together in a single transaction. Build a data structure that, for any query product ID, returns the top k recommended products that are most frequently co-purchased with it. If two products have the same frequency, sort them by ascending product ID to ensure deterministic ordering. The system must support efficient updates as new orders arrive and must handle large input sizes typical of a social-commerce feed.