DAG Permissions III
The nodes of a DAG are named, and edges are [parent, child] pairs of names. Two lists hold the access-control entries: allow names the nodes granted access and deny names the nodes refused it.
Entries are inherited down every edge, and a deny anywhere on the way wins: a node has access when no deny applies to it or to any ancestor and some allow applies to it or to an ancestor. A node that inherits no decision at all is denied.
Return one boolean per node, in the order of names. Nodes may have several parents, the graph may have several roots and disconnected parts, and duplicate edges or entries may appear.
resolvePermissions(["root", "teamA", "teamB", "service"],
[["root", "teamA"], ["root", "teamB"], ["teamA", "service"], ["teamB", "service"]],
["root"], ["teamB"])
-> [true, true, false, false]service inherits root's allow through teamA, but teamB's deny reaches it too, and a deny wins.
Hints
Hint 1
Each node needs just two facts: did an allow reach me, did a deny reach me. Both are ORs over the parents plus the node's own entries.
Hint 2
Process nodes in topological order so both facts are settled at every parent before a child reads them.
Topics
Asked at
Sign in to use the assistant — ask what the problem means, get a hint when you're stuck, or have your current work reviewed. Conversations save to your account.