Top-Selling Books Tracker

Asked at Snowflake · Coding Questions · Difficulty: Medium · Last asked Feb 1, 2026

A bookshop wants a live best-seller list. Sales arrive in batches, and after each batch the shop asks for the current top `k` books by total sales since the tracker was created. Design a class that keeps the running totals and answers that question after every batch.

Loading the problem…