Merge Ranked Results from Multiple Connectors Without Duplicates
Last updated: November 29, 2026
Quick Overview
Each connector (Drive, Confluence, Slack and so on) returns its own list of (score, url) sorted by descending score. Return the global top k results, dropping any result whose canonical URL was already returned with a higher score.
Glean
November 29, 20260
0
0 solved
Each connector (Drive, Confluence, Slack and so on) returns its own list of (score, url) sorted by descending score. Return the global top k results, dropping any result whose canonical URL was already returned with a higher score.
Glean blends results from indexed content and live-retrieval sources, and the same file often surfaces twice through different links. The interviewer checks a k-way merge with a heap, URL canonicalization, and the reasoning that scores must be comparable across sources before merging.
What the Interviewer Expects
- Uses a heap seeded with the head of each list for a k-way merge
- Stops after k unique results instead of merging everything
- Canonicalizes URLs (scheme, query string, fragment, trailing slash) before deduplicating
- Explains that the first occurrence popped is the highest-scoring copy
- Gives O((m + k) log m) complexity for m lists
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
- Scores from different connectors are not calibrated. How would you make them comparable?
- Two different URLs point to the same Google Doc. How else could you detect duplicates?
- One connector is slow. How do you return results within a 300 ms budget?
- How would you add diversity so the top 10 are not all Slack messages?
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: lists, each sorted by score descending, and k. Output: up to k (score, url) pairs in descending score with no two sharing a canonical URL. Assume scores are already calibrated to one sc...
High-Level Design
Push (-score, list_index, position, url) for the head of each list into a max-heap (negated min-heap). Pop the best; if its canonical form is unseen, emit it; then push the next item from the same l...