Resolve a User's Effective Role Through Inherited Folder Collaborations
Last updated: November 29, 2026
Quick Overview
Given a folder tree with parent pointers, folder owners, collaborations granted to users or groups at any folder, and group memberships, return the strongest role a user has on a given file or folder.
Box
November 29, 20260
0
0 solved
Given a folder tree with parent pointers, folder owners, collaborations granted to users or groups at any folder, and group memberships, return the strongest role a user has on a given file or folder.
Box permissions cascade: a collaboration on a folder applies to everything beneath it, and access can come from a direct invite or a group. Onsite interviewers use this to check tree traversal, role ordering, and whether you think about the cost of permission checks that run on every file request.
What the Interviewer Expects
- Walks from the item to the root collecting collaborations
- Expands the user into all principals (user plus groups) before matching
- Orders roles explicitly and keeps the maximum
- Short-circuits on ownership
- Detects cycles or bad data instead of looping forever
- Discusses caching or precomputation for hot paths
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 list every item a user can access without walking each item's ancestors?
- Box allows a collaboration lower in the tree to grant more than an ancestor. What if you had to support restricting access below a folder too?
- Groups can contain groups. How does the principal expansion change?
- How would you invalidate a cache of effective roles when a folder is moved?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Roles are ordered: previewer < viewer < uploader < editor < co-owner < owner. A user's effective role on an item is the maximum over every collaboration on the item or any ancestor that names the user...
High-Level Design
Compute the user's principal set once: the user id plus each group containing them. Then walk parent pointers from the item to the root. At each node, check ownership (return immediately) and fold in ...