This question evaluates understanding of graph traversal and set-based aggregation, with emphasis on handling nested group memberships, cycle-safe expansion, and mapping users to devices.
You are given an access model with nested groups:
When a group is granted access, all users in that group and in any nested subgroups (recursively) have access to their devices.
groupChildren
: a mapping from
groupId -> list of subgroupIds
.
groupUsers
: a mapping from
groupId -> list of userIds
.
userDevices
: a mapping from
userId -> list of deviceIds
.
startGroups
: a list of groupIds that are granted access.
Return the set/list of unique deviceIds that are accessible from startGroups by expanding subgroup membership recursively.
If startGroups = ["G1"], and G1 contains G2, G2 contains user U1, and U1 has devices [D1, D2], then the answer includes D1, D2.