Rank Files by Count of External Domains They Are Shared With
Last updated: November 29, 2026
Quick Overview
Given a list of sharing records (file id, principal) where a principal is an email, a group, or the special value 'anyone' for a public link, return every file exposed outside the organization's internal domains, ranked by how many distinct external domains (counting a public link as one) can reach it.
Concentric Ai
November 29, 20260
0
0 solved
Given a list of sharing records (file id, principal) where a principal is an email, a group, or the special value 'anyone' for a public link, return every file exposed outside the organization's internal domains, ranked by how many distinct external domains (counting a public link as one) can reach it.
A warm-up in the style of a Concentric AI phone screen, built on the core DSPM question of who outside the company can see a file. The interviewer checks clean hashing, careful string normalization of emails and domains, and a deterministic sort.
What the Interviewer Expects
- Normalize case and whitespace before comparing domains
- Treat public links as a distinct exposure category
- Count distinct domains, not raw share records
- Produce a deterministic tie-break in the ranking
- State O(n log n) complexity and why
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
- How would you handle subdomains such as eu.acme.com being internal?
- Group principals can contain external members; how would you expand them?
- How would this run over 500 million share records that do not fit in memory?
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: a list of (file_id, principal) pairs and a set of internal domains. A principal is an email, group:<name>, or anyone. Output: files with any external exposure, as `(file_id, sorted extern...
High-Level Design
One pass builds file_id -> set(domains). For each record, lowercase the principal; anyone adds a sentinel *public*; an email contributes its domain after the last @ if that domain is not inter...