Answer Is-Prerequisite Queries Over a Permission Hierarchy
Last updated: November 29, 2026
Quick Overview
Permissions form a DAG where an edge [a, b] means holding permission a implies permission b. Given n permissions, the edges, and many queries [u, v], return for each query whether holding u implies v, directly or transitively.
Meta
November 29, 20260
0
0 solved
Permissions form a DAG where an edge [a, b] means holding permission a implies permission b. Given n permissions, the edges, and many queries [u, v], return for each query whether holding u implies v, directly or transitively.
A Meta technical screen problem in the style of the access control systems behind internal tools and Business Manager roles. The interviewer is looking for the trade-off between per-query BFS and precomputing reachability, and expects you to choose based on the query volume and graph size.
What the Interviewer Expects
- Compare per-query search with precomputed transitive closure
- Propagate reachability sets in reverse topological order
- Use bitsets or Python ints to make closure cheap
- State time and memory for both approaches
- Answer queries in O(1) after preprocessing
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
- What if n is one million and queries are rare?
- How would you update the closure when a new edge is added?
- How would you support an edge removal efficiently?
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:
npermissions0..n-1, DAGedges[a, b], andqueries[u, v]. - Output: a list of booleans,
Trueifvis reachable fromu. - Clarify sizes: here
nis up to a few hundred and...
High-Level Design
Two options:
- BFS per query:
O(q (n + e)). Fine when queries are rare. - Transitive closure: compute
reach[u], the set of nodes reachable fromu, once. Then each query is a bit test....