This question evaluates reasoning about access-control and transitive relationships, testing skills in graph modeling, reachability, and set operations within permission hierarchies.
You are given permissions data describing which users and groups have ownership access to which cameras, and which entities are members of which groups.
Each permission record is a triple:
(entity_id, relationship, object_id)
Where:
relationship
is one of:
"camera_owner"
:
entity_id
(a user or a group) directly has access to
object_id
(a camera).
"group_member"
:
entity_id
(a user or a group) is a member of
object_id
(a group).
user -> camera_owner -> camera
), or
Return the ID of the single Admin user—defined as the only user who can access every camera referenced anywhere in the data (i.e., every camera_* appearing as the object_id of a "camera_owner" record).
It is guaranteed that exactly one such admin user exists.
permissionsData
: an array/list of triples
(entity_id, relationship, object_id)
.
entity_id
is a string like
"user_1"
or
"group_2"
.
object_id
is a string like
"camera_3"
(for
camera_owner
) or
"group_7"
(for
group_member
).
"user_1"
) for the admin user.
Given:
("user_1", "camera_owner", "camera_1")
("user_1", "group_member", "group_1")
("group_1", "camera_owner", "camera_2")
("group_1", "group_member", "group_2")
("group_2", "camera_owner", "camera_3")
Then user_1 can access camera_1 directly, camera_2 via group_1, and camera_3 via group_1 -> group_2, so user_1 would be the admin in this dataset.