Rank the Most Frequently Cited Cases Across Uploaded Briefs
Last updated: November 29, 2026
Quick Overview
Given a list of briefs, each a list of case ids it cites (possibly repeating), return the k cases cited by the most distinct briefs, breaking ties by case id.
Harvey
November 29, 20260
0
0 solved
Given a list of briefs, each a list of case ids it cites (possibly repeating), return the k cases cited by the most distinct briefs, breaking ties by case id.
Harvey customers upload sets of filings into a workspace and want a quick sense of which authorities dominate. The interviewer is looking for correct counting semantics (once per brief), a heap or sort for top k, and deterministic tie breaking.
What the Interviewer Expects
- Clarify that a case counts once per brief, not per mention
- Use a counter then a heap or sort for top k
- Make tie breaking deterministic
- Discuss O(n + m log k) cost
- Handle k larger than the number of cases
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
- What if briefs stream in and you need the top k at any time?
- How would you weight citations by court level or recency?
- How would you do this across millions of briefs on several machines?
- How would you dedupe the same case cited under different reporters?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: briefs, a list of lists of case ids; integer k. A brief that cites a case three times still counts once, since the goal is how widely an authority is relied on. Output the top k ids by brie...
High-Level Design
Dedupe each brief with a set, then update a Counter. To pick the top k, use heapq.nsmallest with key (-count, id), which keeps a heap of size k instead of sorting every case....