← Questions

Inherited permissions across teams, folders and files

0
FigmaCodingLast asked Jul 2026

Design a permission system for a workspace organized as a hierarchy of teams, folders, and files.

  • A team is a root. It can contain folders and files.
  • A folder sits inside a team or another folder. It can contain folders and files.
  • A file is a leaf. It lives inside a team or a folder and has no children.

Every entity has a unique string uuid and a list of user IDs who were given access to it directly. Access is inherited: a user who has direct access to an entity can access every entity below it, at any depth. Access never flows upward.

Implement a class PermissionSystem with:

  • add_team(uuid, user_ids)
  • add_folder(uuid, parent_uuid, user_ids)
  • add_file(uuid, parent_uuid, user_ids)
  • has_access(user_id, uuid) -> bool: can this user open this entity?
  • accessible_files(user_id) -> list[str]: the IDs of all files the user can open, sorted, each listed once.

Raise an error for a duplicate ID, an unknown parent, or a file used as a parent. Assume up to 10^5 entities and trees that can be deep.

Example

Team studio (users: mia) contains folder brand (users: raj) and file budget (no users). Folder brand contains file palette (users: lee).

  • has_access("mia", "palette") -> True (inherited from studio)
  • has_access("raj", "budget") -> False (budget is not under brand)
  • has_access("lee", "brand") -> False (access does not flow upward)
  • accessible_files("mia") -> ["budget", "palette"]
  • accessible_files("raj") -> ["palette"]

Reconstructed from the reported question; details may differ from what interviewers ask.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding