Top K Sellers by Positive Feedback Rate in a Category
Last updated: November 29, 2026
Quick Overview
Given sellers as (seller_id, positive_ratings, total_ratings), return the k best sellers ranked by positive rate, then by total ratings, then by seller id ascending, skipping sellers with no ratings.
eBay
November 29, 20260
0
0 solved
Given sellers as (seller_id, positive_ratings, total_ratings), return the k best sellers ranked by positive rate, then by total ratings, then by seller id ascending, skipping sellers with no ratings.
eBay surfaces seller feedback percentage everywhere, and category pages may highlight top rated sellers. This phone screen question checks a size-k heap, a precise multi-key ranking, and avoiding floating point ties by comparing rates exactly.
What the Interviewer Expects
- Use a min-heap of size k for O(n log k)
- Encode the three-level tie break in a single comparable key
- Compare rates exactly with fractions or cross multiplication
- Skip zero-rating sellers instead of dividing by zero
- Return results best first
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- A seller with 1 of 1 positive beats one with 9,990 of 10,000. How would you fix the ranking?
- What if feedback arrives as a stream and you must answer top k at any moment?
- How would you compute top k per category across many shards?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Rank by positive rate (higher first), then total ratings (higher first), then seller id (lexicographically smaller first). Sellers with total == 0 are excluded. Return up to k ids, best first....
High-Level Design
Keep a min-heap of the current best k where the root is the weakest. For each seller, build a key where larger means better, push if the heap has room, or replace the root if the new key beats it. Flo...