Find user who can access every camera
Company: Verkada
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
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).
### Access rules
- A user can access a camera if they:
- own it directly (`user -> camera_owner -> camera`), or
- are a member of a group that owns it, including through **nested group membership**.
- Groups can be nested to multiple levels.
- There are **no cycles** in group membership.
- Users can be members of multiple groups.
- Some users may not belong to any group.
### Task
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.
### Input
- `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`).
### Output
- A string user ID (e.g., `"user_1"`) for the admin user.
### Example
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.
### Constraints
- Must run within typical interview-scale limits (e.g., a few seconds).
Quick Answer: This question evaluates reasoning about access-control and transitive relationships, testing skills in graph modeling, reachability, and set operations within permission hierarchies.