Compute Effective Page Access With Inherited and Restricted Permissions

Last updated: November 29, 2026

Quick Overview

Pages form a tree, and each page can grant access levels to users, groups or everyone, either adding to what it inherits from its parent or restricting inheritance so only its own grants apply. Compute one user's effective access on every page in a single pass.

Notion
Coding & Algorithms
Software Engineer
Notion
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Pages form a tree, and each page can grant access levels to users, groups or everyone, either adding to what it inherits from its parent or restricting inheritance so only its own grants apply. Compute one user's effective access on every page in a single pass.

In Notion, sharing flows down the page tree: a teamspace grant applies to nested pages unless a page has been locked down with its own explicit permissions. An onsite coding round on this checks whether the candidate can model inheritance precisely, avoid per-page walks up to the root, and reason about groups and cycles in real data.

What the Interviewer Expects
  • Pin down precedence: highest level wins among matching grants, and restrict cuts off inheritance
  • Expand the user into all principals (self, groups, everyone) before evaluation
  • Do one top-down traversal instead of walking ancestors for every page
  • Detect cycles or orphaned parents instead of looping
  • Explain O(pages + grants) complexity and how results could be cached
Key Topics to Cover
Tree DP
Permission inheritance
Iterative DFS
Cycle detection
Access control
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
  • A page is moved under a different parent. Which cached results must be invalidated?
  • How would you answer a single check(user, page) query without computing the whole tree?
  • Add explicit deny grants that beat any allow. How does the algorithm change?
  • How would you evaluate this for 10,000 users at once, for example to build a search index ACL?
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

Inputs: pages maps page id to parent id (None for a workspace root), grants maps a page to a list of (principal, level, mode), and groups_of_user lists a user's groups. Levels are ordered none...

High-Level Design

Effective level is a function of the parent's effective level plus local grants, which is a top-down tree DP. Build a children map, find roots, and push (page, inherited_level) on a stack. At each p...


Submit Your Answer
Markdown supported

Related Questions