Company: Barclays
Difficulty: medium
Popular Products Analysis The manager of a grocery store tagGrocery wishes to determine which products are most popular with his customers (i.e. which products they purchase most frequently). The manager selects N customers who purchase a shopping bag of items containing M products, each labeled with a productID. By analyzing these M products, the manager wishes to find the productIDs of the distinct products that get purchased most frequently by at least K(given) customers. Write an algorithm to help the manager find the productIDs of the products that are most frequently purchased by the K customers. Input Format First line: Two space-separated integers - tag_row , tag_col , representing the number of customers (N) and the number of products in the shopping bag of the customer (M) Next N lines: M space-separated integers - tag[0], tag[1], ..., tag[M-1] , representing the productIDs of the products contained in the shopping bag of each customer Last line: Integer K_input , representin