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
Coding & Algorithms
Software Engineer
Box
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
Tree traversal
Access control
Role lattices
Group expansion
Caching
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions